結果

問題 No.220 世界のなんとか2
ユーザー kotamanegikotamanegi
提出日時 2017-03-04 14:55:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 979 bytes
コンパイル時間 777 ms
コンパイル使用メモリ 90,732 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-05 05:22:57
合計ジャッジ時間 1,805 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <random>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
long long dp[100][10][2] = {};
int main() {
#define int long long
	int p;
	cin >> p;
	dp[p][0][0] = 1;
	for (int i = p;i > 0;--i) {
		for (int q = 0;q < 3;++q) {
			dp[i - 1][0][1] += dp[i][q][1] * 10;
		}
		for (int q = 0;q < 3;++q) {
			for (int j = 0;j < 10;++j) {
				if (j != 3) {
					dp[i - 1][(q + j) % 3][0] += dp[i][q][0];
				}
				else dp[i - 1][0][1] += dp[i][q][0];
			}
		}
	}
	cout << dp[0][0][0] + dp[0][0][1]-1 << endl;
	return 0;
}
0