結果
問題 | No.1049 Zero (Exhaust) |
ユーザー |
|
提出日時 | 2020-05-08 21:57:24 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 89 ms / 2,000 ms |
コード長 | 604 bytes |
コンパイル時間 | 1,640 ms |
コンパイル使用メモリ | 172,416 KB |
実行使用メモリ | 57,920 KB |
最終ジャッジ日時 | 2024-07-04 00:37:33 |
合計ジャッジ時間 | 3,392 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) using namespace std; using ll = long long ; using P = pair<int,int> ; using pll = pair<long long,long long>; constexpr int INF = 1e9; constexpr long long LINF = 1e17; constexpr int MOD = 1000000007; int main(){ ll p ,k; cin >> p >> k; vector<vector<ll>> dp(k+1,vector<ll>(2,0)); dp[0][0] = 1; for(int i=1;i<=k;i++){ dp[i][0] = (((p+1)*dp[i-1][0])%MOD + (2*dp[i-1][1])%MOD)%MOD; dp[i][1] = (((p-1)*dp[i-1][0])%MOD + ((2*p-2)*dp[i-1][1])%MOD)%MOD; } cout << dp[k][0] << endl; return 0; }