結果
問題 | No.220 世界のなんとか2 |
ユーザー | tottoripaper |
提出日時 | 2015-06-14 11:33:23 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 514 bytes |
コンパイル時間 | 170 ms |
コンパイル使用メモリ | 26,440 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-21 01:21:25 |
合計ジャッジ時間 | 1,216 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 1 ms
4,376 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 2 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 1 ms
4,376 KB |
testcase_10 | AC | 2 ms
4,376 KB |
testcase_11 | AC | 2 ms
4,380 KB |
testcase_12 | AC | 1 ms
4,376 KB |
testcase_13 | AC | 1 ms
4,376 KB |
testcase_14 | AC | 1 ms
4,376 KB |
testcase_15 | AC | 1 ms
4,376 KB |
testcase_16 | AC | 1 ms
4,376 KB |
testcase_17 | AC | 1 ms
4,376 KB |
testcase_18 | AC | 1 ms
4,380 KB |
ソースコード
#include <cstdio> #include <cstring> int p; long long dp[19][10][2]; long long rec(int index, int remainder, bool hasThree){ if(index == p){return remainder == 0 || hasThree;} auto& res = dp[index][remainder][hasThree]; if(res != -1){return res;} res = 0; for(int i=0;i<=9;i++){ res += rec(index+1, (remainder+i) % 3, hasThree || i == 3); } return res; } int main(){ scanf("%d", &p); memset(dp, -1ll, sizeof(dp)); printf("%lld\n", rec(0, 0, false) - 1); }