結果

問題 No.1049 Zero (Exhaust)
ユーザー monnu
提出日時 2021-04-18 00:33:48
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 571 bytes
コンパイル時間 1,621 ms
コンパイル使用メモリ 167,776 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-04 04:23:05
合計ジャッジ時間 2,522 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 200003
#define MOD 1000000007
#define INF 1000000000

ll modpow(ll a,ll x){
  ll ret=1;
  a%=MOD;
  while(x>0){
    if(x%2==1){
      ret=ret*a%MOD;
    }
    x>>=1;
    a=a*a%MOD;
  }
  return ret;
}

int main(){
  ll P,K;
  cin>>P>>K;
  ll sum0=1;
  ll sum1=0;
  for(int i=0;i<K;i++){
    ll a=sum0*(P+1)+sum1*2;
    ll b=sum0*(P-1)+sum1*(2*P-2);
    sum0=a%MOD;
    sum1=b%MOD;
  }
  cout<<sum0<<endl;

}
0