# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
71793 | 내일_개학이다_ㅠㅠ (#119) | Cross on the Grid (FXCUP3_cross) | C++17 | 3 ms | 672 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<bits/stdc++.h>
#define je 1000000007
using namespace std;
long long mat[33][6][6];
long long ans[6], sv[6];
int main(){
mat[0][0][0] = 1;
mat[0][1][0] = 2;
mat[0][2][0] = 1;
mat[0][3][1] = 1;
mat[0][5][1] = 1;
mat[0][4][2] = 1;
mat[0][0][3] = 1;
mat[0][1][3] = 1;
mat[0][2][3] = 1;
mat[0][0][4] = 1;
mat[0][1][4] = 2;
mat[0][3][5] = 1;
for(int i=1;i<=32;i++){
for(int l=0;l<6;l++){
for(int j=0;j<6;j++){
for(int k=0;k<6;k++){
long long cal = (mat[i-1][j][l] * mat[i-1][l][k]) % je;
mat[i][j][k] = (mat[i][j][k] + cal) % je;
}
}
}
}
int n;
scanf("%d", &n);
n-=2;
ans[0] = 1;
for(int ii=0;n;ii++){
if(n%2){
for(int i=0;i<6;i++){sv[i] = ans[i]; ans[i] = 0;}
for(int i=0;i<6;i++){
for(int j=0;j<6;j++){
long long cal = (mat[ii][i][j] * sv[j]) % je;
ans[i] = (ans[i] + cal) % je;
}
}
}
n >>= 1;
}
for(int i=1;i<=5;i++) ans[0] = (ans[0] + ans[i]) % je;
printf("%lld\n", ans[0]);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |