int ra,rb,rc,rd;
mod(a,m)
{
return a<0?mod(a+m,m):a%m;
}
f(a1,b1,c1,d1,m)
{
int a2,b2,c2,d2;
for(a2=m-1;a2>=1;a2--)
{
for(b2=m-1;b2>=1;b2--)
{
for(c2=m-1;c2>=1;c2--)
{
for(d2=m-1;d2>=1;d2--)
{
ra=mod(a1*a2-b1*b2-c1*c2-d1*d2,m);
rb=mod(a1*b2+b1*a2+c1*d2-d1*c2,m);
rc=mod(a1*c2-b1*d2+c1*a2+d1*b2,m);
rd=mod(a1*d2+b1*c2-c1*b2+d1*a2,m);
if(ra==1&&rb==0&&rc==0&&rd==0)
{
ra=a2;rb=b2;rc=c2;rd=d2;
return;
}
}
}
}
}
ra=rb=rc=rd=0;
}
main()
{
int m,t;
scanf("%d%d",&m,&t);
for(;t--;)
{
int a1,b1,c1,d1;
scanf("%d%d%d%d",&a1,&b1,&c1,&d1);
f(a1,b1,c1,d1,m);
printf("%d %d %d %d\n",ra,rb,rc,rd);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
1088 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |