Submission #9461

#TimeUsernameProblemLanguageResultExecution timeMemory
9461yukarikoQuaternion inverse (kriii2_Q)C11
0 / 4
0 ms1088 KiB
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=1;a2<m;a2++) { for(b2=1;b2<m;b2++) { for(c2=1;c2<m;c2++) { for(d2=1;d2<m;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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...