結果

問題 No.220 世界のなんとか2
ユーザー TwizzTwizz
提出日時 2017-05-18 19:37:28
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 653 bytes
コンパイル時間 1,327 ms
コンパイル使用メモリ 161,240 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-18 23:12:09
合計ジャッジ時間 2,468 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include"bits/stdc++.h"

//#include<bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
const ll mod = 10000000000;

int main(){
	int dp[20][2][2][3] = {};
	int n;
	cin >> n;
	n += 1;
	string a="10";
	rep(i, 1, n) {
		a += "0";
	}

	dp[0][0][0][0] = 1;
	rep(i, 0, n)rep(j, 0, 2)rep(k, 0, 2)rep(l, 0, 3) {
		int lim = j ? 9 : a[i] - '0';
		rep(d, 0, lim + 1) {
			dp[i + 1][j || d < lim][k || d == 3][(l + d) % 3] += dp[i][j][k][l];
		}
	}
	int ans = 0;
	rep(j, 0, 2)rep(k, 0, 2)rep(l, 0, 3) {
		if (k || l == 0) { ans += dp[n][j][k][l]; }
	}
	ans--;
	print(ans);
	return 0;
}
0