結果
| 問題 |
No.220 世界のなんとか2
|
| コンテスト | |
| ユーザー |
sashiming
|
| 提出日時 | 2019-08-27 02:12:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,419 bytes |
| コンパイル時間 | 1,690 ms |
| コンパイル使用メモリ | 170,292 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-14 04:16:46 |
| 合計ジャッジ時間 | 2,266 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 19 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)
#define endl '\n'
#define pb push_back
#define eb emplace_back
#define prique priority_queue
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)
const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;
// typedef int_fast64_t ll;
#define int int_fast64_t
template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
int dp[24][2][3][2]; // pos, smllr, mod3, exist3
signed main(void){
cin.tie(0);
ios::sync_with_stdio(false);
int P; cin >> P;
string S = "1";
REP(i, P) S += "0";
dp[0][0][0][0] = 1;
REP(i, S.size()){
int D = S[i]-'0';
REP(j, 2) REP(k, 3) REP(l, 2){
for(int d = 0; d <= (j ? 9 : D); d++){
dp[i+1][j or (d<D)][(k+d)%3][l or d==3] += dp[i][j][k][l];
}
}
}
int ans = 0;
REP(i, 2) REP(j, 3) REP(k, 2){
if(j!=0 and k!=1) continue;
ans += dp[S.size()][i][j][k];
}
cout << ans << endl;
}
sashiming