結果
問題 |
No.1049 Zero (Exhaust)
|
ユーザー |
|
提出日時 | 2020-05-09 22:10:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 788 bytes |
コンパイル時間 | 1,459 ms |
コンパイル使用メモリ | 167,364 KB |
実行使用メモリ | 11,160 KB |
最終ジャッジ日時 | 2024-07-06 05:02:51 |
合計ジャッジ時間 | 2,472 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
// Sakhiya07 - Yagnik Sakhiya #include <bits/stdc++.h> using namespace std; #define ll long long int #define ld long double #define ff first #define ss second #define pb push_back #define all(x) x.begin(),x.end() #define pll pair<int,int> #define mp make_pair #define bp __builtin_popcountll #define MOD 1000000007 const int N = 1000005; void solve() { ll n,p; cin >> p >> n; ll dp[n+1]; dp[0] = 1; ll crt = 1; ll pre = 0; for(ll i=1;i<=n;i++) { dp[i] = (dp[i-1] * (p+1))%MOD; dp[i] = (dp[i] + (2 * pre))%MOD; crt = (crt * 2 * p)%MOD; pre = (crt - dp[i] + MOD)%MOD; } cout<<dp[n]; } int main() { int t = 1; // cin >> t; while(t--) { solve(); } }