Submission #42405
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | #include<bits/stdc++.h> using namespace std; unsigned long long mem[100][10]={{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}}; unsigned long long ans[4]={0}; unsigned long long temp[4]={0}; unsigned long long n,i,j,k,f=0; unsigned long long syori(unsigned long long cnt,unsigned long long cnt2); int main(){ ans[0]=1; ans[1]=1; mem[0][0]=1; mem[0][2]=1; mem[0][3]=1; mem[0][6]=1; mem[0][7]=1; cin>>n; syori(1,1); //cout<<ans[0]<<" "<<ans[1]<<" "<<ans[2]<<" "<<ans[3]<<endl; cout<<(ans[1]+ans[2]+ans[3])%1000000007<<endl; return (0); } unsigned long long syori(unsigned long long cnt,unsigned long long cnt2){ if (cnt==n){ return (0); } i=(unsigned long long )log2(( double )cnt2); //cout<<i<<endl; if (f==0){ mem[i+1][0]=cnt2*2; for (j=1;j<4;j++){ for (k=1;k<4;k++){ mem[i+1][k]+=mem[i][j]*mem[i][k+((j-1)*3)]; mem[i+1][k]%=1000000007; //cout<<k<<" "<<j<<" "<<k+((j-1)*3)<<endl; } } for (j=4;j<7;j++){ for (k=1;k<4;k++){ mem[i+1][k+3]+=mem[i][j]*mem[i][k+((j-4)*3)]; mem[i+1][k+3]%=1000000007; //cout<<k+3<<" "<<j<<" "<<k+((j-4)*3)<<endl; } } for (j=7;j<10;j++){ for (k=1;k<4;k++){ mem[i+1][k+6]+=mem[i][j]*mem[i][k+((j-7)*3)]; mem[i+1][k+6]%=1000000007; //cout<<k+6<<" "<<j<<" "<<k+((j-7)*3)<<endl; } } if (cnt+cnt2<=n){ cnt+=cnt2; ans[0]+=cnt2; for (j=1;j<4;j++){ for (k=1;k<4;k++){ temp[k]+=ans[j]*mem[i][k+(3*(j-1))]; temp[k]%=1000000007; } } for (j=1;j<4;j++){ ans[j]=temp[j]; temp[j]=0; } syori(cnt,cnt2*2); } else { f=1; syori(cnt,cnt2/2); } return (0); } else { if (ans[0]+cnt2<=n){ cnt+=cnt2; ans[0]+=cnt2; for (j=1;j<4;j++){ for (k=1;k<4;k++){ temp[k]+=ans[j]*mem[i][k+(3*(j-1))]; temp[k]%=1000000007; } } for (j=1;j<4;j++){ ans[j]=temp[j]; temp[j]=0; } } syori(cnt,cnt2/2); return (0); } } |
ステータス
項目 | データ |
---|---|
問題 | 0564 - 剣剣波(large) |
ユーザー名 | 珈琲の素材は虚数渦動 |
投稿日時 | 2018-08-31 10:42:38 |
言語 | C++11 |
状態 | Accepted |
得点 | 1 |
ソースコード長 | 2030 Byte |
最大実行時間 | 58 ms |
最大メモリ使用量 | 708 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 1 / 1 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
00.in | AC | 27 ms | 480 KB |
1
|
00sample.in | AC | 38 ms | 452 KB |
1
|
01.in | AC | 20 ms | 552 KB |
1
|
01sample.in | AC | 22 ms | 524 KB |
1
|
02.in | AC | 28 ms | 628 KB |
1
|
02sample.in | AC | 20 ms | 604 KB |
1
|
03.in | AC | 25 ms | 708 KB |
1
|
04.in | AC | 58 ms | 680 KB |
1
|
05.in | AC | 36 ms | 648 KB |
1
|
06.in | AC | 27 ms | 620 KB |
1
|
07.in | AC | 25 ms | 596 KB |
1
|