# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
9588 | pichulia | Quaternion inverse (kriii2_Q) | C++98 | 492 ms | 1248 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef vector<vector<long long int> > mat;
typedef vector<long long int> vi;
long long MOD = 1000000007;
// a^(-1) mod m (NOTE. m must be prime)
long long int gcd_ext(long long int a,long long int m)
{
long long int x,y,q,s[2],t[2],i;
int l1,l2;
l1=0;l2=1;
s[0]=1;t[0]=0;
s[1]=0;t[1]=1;
x=m;y=a;
for(i=2;y;i++)
{
q=x/y;
s[l1]=s[l1]-q*s[l2];
t[l1]=t[l1]-q*t[l2];
l1^=l2^=l1^=l2;
y^=x^=y^=x%=y;
}
return (t[l1]+m+m)%m;
}
mat mat_add(mat &v1,mat &v2){
mat ret(v1.size(),vi(v1[0].size()));
for(int i=0;i<v1.size();i++)
for(int j=0;j<v1[0].size();j++)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |