結果
| 問題 | No.220 世界のなんとか2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-02-06 22:14:26 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 949 bytes |
| 記録 | |
| コンパイル時間 | 1,394 ms |
| コンパイル使用メモリ | 158,600 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-21 20:55:22 |
| 合計ジャッジ時間 | 2,053 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 WA * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXP = 19 + 1;
int n;
int a[MAXP];
ll way[MAXP][2][2][3]; // how many digits selected, strictly less, has 3, % 3
int main(){
cin >> n;
a[0] = 1;
for(int i = 1; i < n; ++i)
a[i] = 0;
++n;
way[0][0][0][0] = 1LL;
for(int i = 0; i < n; ++i)
for(int j = 0; j < 2; ++j)
for(int k = 0; k < 2; ++k)
for(int l = 0; l < 3; ++l){
int lim = j ? 9 : a[i];
for(int d = 0; d <= lim; ++d)
way[i + 1][j || d < lim][k || d == 3][ ( l + d ) % 3 ]
+= way[i][j][k][l];
}
ll ans = 0LL;
for(int j = 0; j < 2; ++j)
for(int k = 0; k < 2; ++k)
for(int l = 0; l < 3; ++l)
if( k || l == 0 )
ans += way[n][j][k][l];
cout << ans - 1 << endl;
return 0;
}