結果

問題 No.1049 Zero (Exhaust)
ユーザー umezo
提出日時 2020-05-08 22:30:31
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 615 bytes
コンパイル時間 2,612 ms
コンパイル使用メモリ 214,944 KB
最終ジャッジ日時 2025-01-10 09:01:24
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#include <bits/stdc++.h>
using namespace std;

#define MOD 1000000007


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

  return 0;
}
0