結果
| 問題 |
No.220 世界のなんとか2
|
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2018-12-04 13:09:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 561 bytes |
| コンパイル時間 | 1,757 ms |
| コンパイル使用メモリ | 192,000 KB |
| 最終ジャッジ日時 | 2025-01-06 18:08:30 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//INSERT ABOVE HERE
Int n;
Int dp[2][3][20];
Int dfs(Int f,Int x,Int i){
if(i==n) return f||!x;
Int &res=dp[f][x][i];
if(~res) return res;
res=0;
for(Int k=0;k<10;k++){
res+=dfs(f||(k==3),(x*10+k)%3,i+1);
}
return res;
}
signed main(){
cin>>n;
memset(dp,-1,sizeof(dp));
cout<<dfs(0,0,0)-1<<endl;
return 0;
}
beet