結果

問題 No.1049 Zero (Exhaust)
ユーザー chocoruskchocorusk
提出日時 2020-05-08 21:34:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 894 bytes
コンパイル時間 1,196 ms
コンパイル使用メモリ 127,868 KB
実行使用メモリ 19,240 KB
最終ジャッジ日時 2024-07-04 00:06:07
合計ジャッジ時間 2,270 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
18,996 KB
testcase_01 AC 7 ms
19,068 KB
testcase_02 AC 6 ms
19,004 KB
testcase_03 AC 13 ms
19,060 KB
testcase_04 AC 6 ms
19,080 KB
testcase_05 AC 13 ms
19,072 KB
testcase_06 AC 17 ms
19,036 KB
testcase_07 AC 7 ms
19,044 KB
testcase_08 AC 9 ms
18,916 KB
testcase_09 AC 15 ms
19,076 KB
testcase_10 AC 15 ms
19,028 KB
testcase_11 AC 17 ms
19,052 KB
testcase_12 AC 18 ms
18,932 KB
testcase_13 AC 10 ms
19,104 KB
testcase_14 AC 11 ms
18,988 KB
testcase_15 AC 15 ms
19,240 KB
testcase_16 AC 12 ms
19,040 KB
testcase_17 AC 13 ms
19,064 KB
testcase_18 AC 15 ms
18,940 KB
testcase_19 AC 14 ms
19,072 KB
testcase_20 AC 11 ms
18,960 KB
testcase_21 AC 14 ms
19,072 KB
testcase_22 AC 11 ms
19,040 KB
testcase_23 AC 17 ms
19,096 KB
testcase_24 AC 18 ms
19,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
	ll dp[1000010][2]={};
	dp[0][0]=1;
	ll p; int k; cin>>p>>k;
	for(int i=1; i<=k; i++){
		dp[i][0]=(dp[i-1][0]+dp[i-1][1]*(p-1))%MOD;
		(dp[i][0]+=dp[i-1][0]*p+dp[i-1][1]*(p-1))%=MOD;
		dp[i][1]=(dp[i-1][0]+dp[i-1][1]*(p-1))%MOD;
		(dp[i][1]+=dp[i-1][1]*(p-1))%=MOD;
	}
	cout<<dp[k][0]<<endl;
	return 0;
}
0