結果

問題 No.1049 Zero (Exhaust)
ユーザー CleyLCleyL
提出日時 2023-03-24 10:25:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 343 bytes
コンパイル時間 534 ms
コンパイル使用メモリ 68,348 KB
実行使用メモリ 19,192 KB
最終ジャッジ日時 2023-10-18 19:59:58
合計ジャッジ時間 1,624 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 11 ms
14,476 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 10 ms
12,428 KB
testcase_06 AC 16 ms
19,192 KB
testcase_07 AC 4 ms
6,284 KB
testcase_08 AC 6 ms
8,332 KB
testcase_09 AC 12 ms
16,524 KB
testcase_10 AC 13 ms
16,524 KB
testcase_11 AC 13 ms
16,524 KB
testcase_12 AC 14 ms
18,572 KB
testcase_13 AC 5 ms
8,332 KB
testcase_14 AC 8 ms
10,380 KB
testcase_15 AC 11 ms
14,476 KB
testcase_16 AC 9 ms
12,428 KB
testcase_17 AC 11 ms
14,476 KB
testcase_18 AC 14 ms
18,572 KB
testcase_19 AC 12 ms
16,524 KB
testcase_20 AC 6 ms
8,332 KB
testcase_21 AC 12 ms
16,524 KB
testcase_22 AC 8 ms
10,380 KB
testcase_23 AC 16 ms
19,192 KB
testcase_24 AC 16 ms
19,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;
const long long MOD = 1000000007;

long long dp[1000010][2];

int main(){
  int p,k;cin>>p>>k;
  dp[0][0] = 1;
  for(int i = 0; k > i; i++){
    dp[i+1][0] = (((dp[i][0]*(p+1))%MOD) + dp[i][1]*2)%MOD;
    dp[i+1][1] = (((dp[i][0]*(p-1))%MOD) + dp[i][1]*(2*p-2))%MOD;
  }
  cout << dp[k][0] << endl;
}
0