結果

問題 No.220 世界のなんとか2
ユーザー kwkm0429kwkm0429
提出日時 2018-01-22 14:38:40
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 778 bytes
コンパイル時間 1,567 ms
コンパイル使用メモリ 144,116 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-26 21:03:35
合計ジャッジ時間 2,591 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 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 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define EPS (1e-7)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX=1e9;

int main(){
	int p;
	cin>>p;
	ll dp[p+1][3][2]; //digit,mod,exist3
	REP(i,p+1)REP(j,3)REP(k,2)dp[i][j][k]=0;
	dp[0][0][0]=1;
	REP(i,p)REP(j,3)REP(k,10)REP(l,2){
		dp[i+1][(j+k)%3][l || k==3]+=dp[i][j][l];
	}
	ll ans=0;
	ans+=dp[p][0][0]+dp[p][0][1];
	ans+=dp[p][1][1]+dp[p][2][1];
	cout<<ans-1<<endl;
	return 0;
}
0