Submission #9457

# Submission time Handle Problem Language Result Execution time Memory
9457 2014-09-28T06:34:44 Z yukariko Quaternion inverse (kriii2_Q) C
0 / 4
0 ms 1088 KB
int ra,rb,rc,rd;
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+rc+rd==0)
          {
            ra=a2;rb=b2;rc=c2;rd=d2;
            return;
          }
        }
      }
    }
  }
  ra=rb=rc=rd=0;
}
mod(a,m)
{
  return a<0?mod(a+m,m):a%m;
}
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 -