結果
問題 | No.362 門松ナンバー |
ユーザー | kotatsugame |
提出日時 | 2020-03-05 16:38:48 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 156 ms / 3,000 ms |
コード長 | 1,078 bytes |
コンパイル時間 | 682 ms |
コンパイル使用メモリ | 77,056 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-04-22 02:37:14 |
合計ジャッジ時間 | 3,717 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
6,816 KB |
testcase_01 | AC | 32 ms
6,944 KB |
testcase_02 | AC | 31 ms
6,944 KB |
testcase_03 | AC | 17 ms
6,940 KB |
testcase_04 | AC | 11 ms
6,940 KB |
testcase_05 | AC | 52 ms
6,940 KB |
testcase_06 | AC | 95 ms
6,944 KB |
testcase_07 | AC | 55 ms
6,944 KB |
testcase_08 | AC | 73 ms
6,944 KB |
testcase_09 | AC | 120 ms
6,940 KB |
testcase_10 | AC | 153 ms
6,940 KB |
testcase_11 | AC | 149 ms
6,944 KB |
testcase_12 | AC | 150 ms
6,940 KB |
testcase_13 | AC | 152 ms
6,944 KB |
testcase_14 | AC | 149 ms
6,940 KB |
testcase_15 | AC | 151 ms
6,944 KB |
testcase_16 | AC | 147 ms
6,944 KB |
testcase_17 | AC | 132 ms
6,944 KB |
testcase_18 | AC | 156 ms
6,944 KB |
testcase_19 | AC | 77 ms
6,944 KB |
testcase_20 | AC | 156 ms
6,944 KB |
testcase_21 | AC | 18 ms
6,944 KB |
コンパイルメッセージ
main.cpp:46:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 46 | main() | ^~~~
ソースコード
#include<iostream> #include<vector> #include<algorithm> using namespace std; long count(long L) { vector<int>S; while(L) { S.push_back(L%10); L/=10; } reverse(S.begin(),S.end()); long dp[20][2][11][11][11]={}; dp[0][0][10][10][10]=1; for(int i=0;i<S.size();i++)for(int j=0;j<2;j++) { int lim=j?9:S[i]; for(int a=0;a<=10;a++)for(int b=0;b<=10;b++)for(int c=0;c<=10;c++) { if(dp[i][j][a][b][c]==0)continue; for(int d=c==10;d<=lim;d++) { if(b<10) { if(b!=c&&c!=d&&d!=b&&(b<c&&d<c||b>c&&d>c)) { dp[i+1][j||d<lim][b][c][d]+=dp[i][j][a][b][c]; } } else { dp[i+1][j||d<lim][b][c][d]+=dp[i][j][a][b][c]; } } if(c==10)dp[i+1][1][b][c][10]+=dp[i][j][a][b][c]; } } long ret=0; for(int a=0;a<10;a++)for(int b=0;b<10;b++)for(int c=0;c<10;c++) { ret+=dp[S.size()][0][a][b][c]+dp[S.size()][1][a][b][c]; } return ret; } main() { int T;cin>>T; for(;T--;) { long K; cin>>K; long L=100,R=1e15; while(R-L>1) { long M=(L+R)/2; if(count(M)>=K)R=M; else L=M; } cout<<R<<endl; } }