Submission #71719

#TimeUsernameProblemLanguageResultExecution timeMemory
71719퍼솔 가즈아ㅏㅏㅏ (#119)Cross on the Grid (FXCUP3_cross)C++14
100 / 100
4 ms900 KiB
#include <cstdio> typedef struct{ long long M[9][9]; } mat; mat A; long long X[9][9]={1,0,0,0,1,0,1,1,0, 1,0,0,0,0,0,1,1,0, 1,0,0,0,1,0,0,1,0, 1,0,0,0,1,0,1,0,0, 0,1,0,0,0,0,0,0,1, 0,1,0,0,0,0,0,0,0, 0,0,1,0,0,0,0,0,0, 0,0,0,1,0,1,0,0,0, 0,0,0,1,0,0,0,0,0}; mat matmul(mat x, mat y){ mat ret; for(int i=0;i<9;i++){ for(int j=0;j<9;j++){ ret.M[i][j]=0LL; } } for(int i=0;i<9;i++){ for(int j=0;j<9;j++){ for(int k=0;k<9;k++){ ret.M[i][k]=(ret.M[i][k]+x.M[i][j]*y.M[j][k])%1000000007LL; } } } return ret; } mat matpow(mat x, int p){ if(p==1) return x; mat h=matpow(x,p/2); if(p&1) return matmul(matmul(h,h),x); return matmul(h,h); } mat ans; long long pans=0LL; int main(){ int N; scanf("%d",&N); for(int i=0;i<9;i++){ for(int j=0;j<9;j++){ A.M[i][j]=X[i][j]; } } ans=matpow(A,N-2); for(int i=0;i<9;i++) pans=(pans+ans.M[i][0])%1000000007LL; printf("%lld",pans); }

Compilation message (stderr)

cross.cpp: In function 'int main()':
cross.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&N);
     ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...