結果

問題 No.220 世界のなんとか2
ユーザー reew2nreew2n
提出日時 2015-05-29 23:09:05
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 952 bytes
コンパイル時間 1,298 ms
コンパイル使用メモリ 144,392 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 16:48:54
合計ジャッジ時間 2,229 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b)  FOR(i,0,b)
#define X real()
#define Y imag()
#define F first
#define S second
#define PB(a) push_back(a)
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef pair<int,long double> pr;
typedef pair<pr,int> ppr;
typedef priority_queue<pr,vector<pr>,greater<pr> > PQ;
typedef vector<pr> Vpr;
typedef vector<LL> VI;
typedef complex<LL> cld;
typedef vector<cld> Vcld;
typedef map<pr,int> MP;
const int SIZE=100010;
const LL INF=1<<28;
LL isT[20]={1},isnT[20]={8};
LL DP[21][3];
LL e(LL k){
	LL ans=1;
	REP(i,k){
		ans*=10;
	}
	return ans;
}

int main(){
	int p;
	cin >>p;
	REP(i,p){
		isT[i+1]=isnT[i]+isT[i]*10;
		isnT[i+1]=-isT[i+1]+(e(i+1))*9;
	}
	LL ans=0;
	REP(i,p){
		ans+=isT[i];
	}
	DP[0][0]=1;
	REP(i,p){
		REP(j,10){
			REP(k,3){
				if(j==3) continue;
				DP[i+1][(j+k)%3]+=DP[i][k];
			}
		}
	}
	cout << ans+DP[p][0]-1<< endl;
}
0