結果
問題 | No.1269 I hate Fibonacci Number |
ユーザー | butsurizuki |
提出日時 | 2020-10-23 23:44:38 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 124 ms / 3,000 ms |
コード長 | 1,570 bytes |
コンパイル時間 | 1,951 ms |
コンパイル使用メモリ | 182,652 KB |
実行使用メモリ | 202,576 KB |
最終ジャッジ日時 | 2023-09-28 19:04:23 |
合計ジャッジ時間 | 8,180 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 112 ms
200,392 KB |
testcase_01 | AC | 95 ms
199,560 KB |
testcase_02 | AC | 102 ms
200,672 KB |
testcase_03 | AC | 98 ms
200,324 KB |
testcase_04 | AC | 97 ms
199,888 KB |
testcase_05 | AC | 95 ms
200,776 KB |
testcase_06 | AC | 93 ms
199,516 KB |
testcase_07 | AC | 95 ms
199,868 KB |
testcase_08 | AC | 95 ms
199,464 KB |
testcase_09 | AC | 95 ms
200,436 KB |
testcase_10 | AC | 95 ms
200,052 KB |
testcase_11 | AC | 95 ms
200,028 KB |
testcase_12 | AC | 95 ms
199,344 KB |
testcase_13 | AC | 104 ms
200,636 KB |
testcase_14 | AC | 115 ms
199,672 KB |
testcase_15 | AC | 102 ms
200,412 KB |
testcase_16 | AC | 121 ms
201,936 KB |
testcase_17 | AC | 97 ms
199,572 KB |
testcase_18 | AC | 116 ms
201,260 KB |
testcase_19 | AC | 111 ms
199,904 KB |
testcase_20 | AC | 102 ms
199,644 KB |
testcase_21 | AC | 110 ms
199,852 KB |
testcase_22 | AC | 112 ms
201,292 KB |
testcase_23 | AC | 108 ms
199,944 KB |
testcase_24 | AC | 105 ms
200,740 KB |
testcase_25 | AC | 104 ms
200,412 KB |
testcase_26 | AC | 98 ms
199,876 KB |
testcase_27 | AC | 96 ms
201,100 KB |
testcase_28 | AC | 102 ms
200,260 KB |
testcase_29 | AC | 107 ms
199,544 KB |
testcase_30 | AC | 100 ms
200,064 KB |
testcase_31 | AC | 119 ms
200,204 KB |
testcase_32 | AC | 106 ms
200,436 KB |
testcase_33 | AC | 124 ms
201,464 KB |
testcase_34 | AC | 105 ms
200,568 KB |
testcase_35 | AC | 105 ms
200,392 KB |
testcase_36 | AC | 116 ms
201,960 KB |
testcase_37 | AC | 99 ms
199,508 KB |
testcase_38 | AC | 114 ms
202,576 KB |
ソースコード
#include<bits/stdc++.h> #define mod 1000000007 using namespace std; using Graph=vector<vector<int>>; long long remtop(long long v){ if(v<10){return 0;} string mem=to_string(v); mem.erase(0,1); return stoll(mem); } int main(){ set<long long> st; map<long long,int> mp; long long n,a,b; cin >> n >> a >> b; long long f[128]; f[0]=1;f[1]=1; for(int i=0;;i++){ if(i>=2){f[i]=f[i-1]+f[i-2];} if(f[i]>b){break;} if(f[i]<a){continue;} mp[f[i]]=-1; long long v=f[i]; while(v>0){ st.insert(v); v/=10; } } st.insert(0); int c=0; long long val[524288]; for(auto x: st){ if(mp[x]==-1){continue;} //printf("[[[%lld]]]\n",x); mp[x]=c; val[c]=x; c++; } //printf("%d\n",mp[55]); Graph g(c); for(int i=0;i<c;i++){ long long cv=val[i]; for(long long j=0;j<10;j++){ long long nv=cv*10+j; long long k=0; while(nv>0){ if(mp[nv]==-1){k=-1;break;} if(mp[nv]!=0 && k==0){k=mp[nv];} nv=remtop(nv); } //printf("%d(%d + %d) -> %d\n",i,cv,j,k); if(k==-1){continue;} g[i].push_back(k); } } long long dp[5005][5005]={0},res=0; for(int i=0;i<n;i++){ for(int j=0;j<c;j++){ if(dp[i][j]==0){continue;} for(auto nx : g[j]){ dp[i+1][nx]+=dp[i][j]; } } for(int j=1;j<10;j++){ if(mp[j]!=-1){ dp[i+1][mp[j]]++; } } res=0; for(int j=0;j<c;j++){ dp[i+1][j]%=mod; res+=dp[i+1][j]; } res%=mod; } printf("%lld\n",res); return 0; }