Submission #62608

#TimeUsernameProblemLanguageResultExecution timeMemory
62608imsifileCross on the Grid (FXCUP3_cross)C++14
100 / 100
3 ms540 KiB
#include<stdio.h> #include<memory.h> typedef long long lld; const lld mod = 1000000007; struct mat { lld ba[9][9]; mat operator* (const mat &c){ mat res; memset(res.ba, 0, sizeof(res.ba)); for(int i=0; i<9; i++){ for(int j=0; j<9; j++){ for(int k=0; k<9; k++) res.ba[i][j] += ba[i][k]*c.ba[k][j]; res.ba[i][j] %= mod; } } return res; } } base, res; int N; int main(){ scanf("%d", &N); N-=4; if(N<0){ puts("4"); return 0; } memset(base.ba, 0, sizeof(base.ba)); memset(res.ba, 0, sizeof(res.ba)); for(int i=0; i<9; i++) res.ba[i][i] = 1; base.ba[0][0] = base.ba[0][1] = base.ba[0][2] = base.ba[0][3] = 1; base.ba[1][4] = base.ba[1][5] = base.ba[2][6] = base.ba[3][7] = base.ba[3][8] = 1; base.ba[4][0] = base.ba[4][2] = base.ba[4][3] = 1; base.ba[6][0] = base.ba[6][1] = base.ba[6][3] = 1; base.ba[7][0] = base.ba[7][1] = base.ba[7][2] = 1; base.ba[5][7] = base.ba[8][4] = 1; for(; N; N>>=1){ if(N&1) res = res*base; base = base*base; } lld sum=0; for(int i=0; i<9; i++){ for(int j=0; j<9; j++) sum += res.ba[i][j]; } printf("%lld\n", sum%mod); return 0; }

Compilation message (stderr)

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