結果
問題 | No.220 世界のなんとか2 |
ユーザー |
![]() |
提出日時 | 2015-06-14 11:33:23 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 514 bytes |
コンパイル時間 | 140 ms |
コンパイル使用メモリ | 23,936 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-06 20:06:01 |
合計ジャッジ時間 | 704 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:22:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 22 | scanf("%d", &p); | ~~~~~^~~~~~~~~~
ソースコード
#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); }