結果
| 問題 | No.1049 Zero (Exhaust) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-03-25 12:07:14 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 16 ms / 2,000 ms | 
| コード長 | 422 bytes | 
| コンパイル時間 | 3,538 ms | 
| コンパイル使用メモリ | 252,564 KB | 
| 最終ジャッジ日時 | 2025-02-11 18:01:59 | 
| ジャッジサーバーID (参考情報) | judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 22 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll) (n); i++)
using mint =modint1000000007;
using vm = vector<mint>;
int main() {
    ll P,K;
    cin>>P>>K;
    vm D(K+1,0),E(K+1,0);
    D[0]=1;
    rep(i,K){
        E[i+1]=(D[i]+2*E[i])*(P-1);
        D[i+1]=2*E[i]+D[i]*(P+1);
    }
    cout<<D[K].val()<<endl;
}
            
            
            
        