| 比赛 | 20131026 | 评测结果 | TWWWWWWWWT |
|---|---|---|---|
| 题目名称 | drei | 最终得分 | 0 |
| 用户昵称 | 明天 | 运行时间 | 2.002 s |
| 代码语言 | C++ | 内存使用 | 0.31 MiB |
| 提交时间 | 2015-09-12 19:51:57 | ||
#include <iostream>
#include <cstdio>
using namespace std;
int t;
int a,p,x,y;
int main()
{
freopen("drei.in","r",stdin);
freopen("drei.out","w",stdout);
scanf("%d",&t);
while (t--)
{
scanf("%d%d",&a,&p);
x=1; y=a;
while (y>0 && y!=1)
{
y=y*a%p; x++;
}
if (y>0)
printf("%d\n",x);
else
printf("-1\n");
}
return 0;
}