結果

問題 No.1049 Zero (Exhaust)
ユーザー umezoumezo
提出日時 2020-05-08 22:30:31
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 615 bytes
コンパイル時間 2,241 ms
コンパイル使用メモリ 221,704 KB
実行使用メモリ 19,168 KB
最終ジャッジ日時 2023-09-17 03:08:52
合計ジャッジ時間 3,483 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 9 ms
14,040 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 9 ms
12,160 KB
testcase_06 AC 13 ms
19,168 KB
testcase_07 AC 3 ms
5,288 KB
testcase_08 AC 6 ms
8,020 KB
testcase_09 AC 10 ms
15,100 KB
testcase_10 AC 11 ms
16,112 KB
testcase_11 AC 11 ms
16,200 KB
testcase_12 AC 13 ms
18,116 KB
testcase_13 AC 5 ms
6,668 KB
testcase_14 AC 6 ms
10,012 KB
testcase_15 AC 9 ms
14,296 KB
testcase_16 AC 8 ms
12,140 KB
testcase_17 AC 8 ms
12,560 KB
testcase_18 AC 12 ms
16,356 KB
testcase_19 AC 9 ms
14,528 KB
testcase_20 AC 6 ms
7,848 KB
testcase_21 AC 10 ms
14,632 KB
testcase_22 AC 7 ms
9,692 KB
testcase_23 AC 12 ms
18,960 KB
testcase_24 AC 13 ms
18,976 KB
権限があれば一括ダウンロードができます

ソースコード

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