結果

問題 No.1049 Zero (Exhaust)
ユーザー leaf_1415leaf_1415
提出日時 2020-05-08 21:45:48
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 1,152 bytes
コンパイル時間 516 ms
コンパイル使用メモリ 74,224 KB
実行使用メモリ 18,988 KB
最終ジャッジ日時 2023-09-17 02:27:56
合計ジャッジ時間 2,097 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 29 ms
14,060 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 24 ms
12,056 KB
testcase_06 AC 40 ms
18,952 KB
testcase_07 AC 7 ms
5,556 KB
testcase_08 AC 14 ms
8,212 KB
testcase_09 AC 31 ms
15,032 KB
testcase_10 AC 33 ms
16,252 KB
testcase_11 AC 33 ms
16,168 KB
testcase_12 AC 39 ms
18,132 KB
testcase_13 AC 11 ms
6,656 KB
testcase_14 AC 18 ms
10,004 KB
testcase_15 AC 28 ms
14,304 KB
testcase_16 AC 24 ms
12,124 KB
testcase_17 AC 25 ms
12,768 KB
testcase_18 AC 34 ms
16,348 KB
testcase_19 AC 29 ms
14,600 KB
testcase_20 AC 13 ms
7,820 KB
testcase_21 AC 30 ms
14,668 KB
testcase_22 AC 18 ms
9,756 KB
testcase_23 AC 41 ms
18,988 KB
testcase_24 AC 41 ms
18,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint p, k;
llint dp[1000005][2];


int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> p >> k;
	
	dp[0][0] = 1;
	for(int i = 0; i < k; i++){
		for(int j = 0; j < 2; j++){
			dp[i+1][0] += dp[i][j], dp[i+1][0] %= mod;
			dp[i+1][1] += dp[i][j] * (p-1) % mod, dp[i+1][1] %= mod;
			
			if(j == 0) dp[i+1][0] += dp[i][j] * p % mod, dp[i+1][0] %= mod;
			else{
				dp[i+1][0] += dp[i][j], dp[i+1][0] %= mod;
				dp[i+1][1] += dp[i][j] * (p-1) % mod, dp[i+1][1] %= mod;
			}
		}
	}
	cout << dp[k][0] << endl;
	
	return 0;
}
0