結果
問題 | No.220 世界のなんとか2 |
ユーザー |
![]() |
提出日時 | 2016-11-26 19:17:04 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 390 bytes |
コンパイル時間 | 1,428 ms |
コンパイル使用メモリ | 165,904 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 11:38:47 |
合計ジャッジ時間 | 2,238 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>using namespace std;int n; long long dp[22][3];int main() {cin >> n;dp[0][0] = 1;long long mul = 1;for(int i = 1; i <= n; i++) {mul *= 10;for(int j = 0; j < 3; j++) {for(int k = 0; k <= 9; k++) {if(k == 3) continue;dp[i][j] += dp[i - 1][(j - k % 3 + 3) % 3];}}}cout << (mul - 1) - (dp[n][1] + dp[n][2]) << endl;return 0;}