結果

問題 No.1049 Zero (Exhaust)
ユーザー yuji9511yuji9511
提出日時 2020-05-08 22:11:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 830 bytes
コンパイル時間 1,427 ms
コンパイル使用メモリ 164,316 KB
実行使用メモリ 19,032 KB
最終ジャッジ日時 2023-09-17 02:57:58
合計ジャッジ時間 2,699 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 12 ms
15,696 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 11 ms
13,600 KB
testcase_06 AC 17 ms
18,984 KB
testcase_07 AC 5 ms
5,288 KB
testcase_08 AC 7 ms
9,556 KB
testcase_09 AC 13 ms
15,616 KB
testcase_10 AC 14 ms
17,688 KB
testcase_11 AC 13 ms
17,964 KB
testcase_12 AC 15 ms
18,228 KB
testcase_13 AC 5 ms
7,428 KB
testcase_14 AC 8 ms
11,552 KB
testcase_15 AC 12 ms
15,696 KB
testcase_16 AC 10 ms
13,588 KB
testcase_17 AC 10 ms
13,648 KB
testcase_18 AC 14 ms
17,684 KB
testcase_19 AC 12 ms
15,696 KB
testcase_20 AC 7 ms
9,492 KB
testcase_21 AC 12 ms
15,628 KB
testcase_22 AC 9 ms
11,736 KB
testcase_23 AC 16 ms
18,984 KB
testcase_24 AC 16 ms
19,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dp[1000010][2] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll P,K;
    cin >> P >> K;
    dp[0][0] = 1;
    rep(i,0,K){
        dp[i+1][0] = dp[i][0] * (P+1) % MOD + dp[i][1] * 2 * (P-1);
        dp[i+1][0] %= MOD;
        dp[i+1][1] = dp[i][0] + (P-1) * 2 * dp[i][1];
        dp[i+1][1] %= MOD;
    }
    ll ans = dp[K][0];
    print(ans);
}
0