結果
| 問題 |
No.220 世界のなんとか2
|
| コンテスト | |
| ユーザー |
koyumeishi
|
| 提出日時 | 2015-05-29 22:55:33 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 792 bytes |
| コンパイル時間 | 1,116 ms |
| コンパイル使用メモリ | 73,640 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-06 11:49:13 |
| 合計ジャッジ時間 | 1,099 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
using namespace std;
long long dp[20][2][2][3];
long long func(int p){
dp[0][0][0][0] = 1;
for(int d=0; d<p; d++){
for(int i=0; i<10; i++){
for(int j=0; j<2; j++){
for(int k=0; k<2; k++){
for(int x=0; x<3; x++){
if(i==3){
dp[d+1][1][1][(x+i)%3] += dp[d][j][k][x];
}else if(i!=0){
dp[d+1][1][k][(x+i)%3] += dp[d][j][k][x];
}else{
dp[d+1][j][k][(x+i)%3] += dp[d][j][k][x];
}
}
}
}
}
}
return dp[p][1][0][0] + dp[p][1][1][0] + dp[p][1][1][1] + dp[p][1][1][2];
}
int main(){
long long p;
cin >> p;
cout << func(p) << endl;
return 0;
}
koyumeishi