結果

問題 No.1049 Zero (Exhaust)
ユーザー yataro800yataro800
提出日時 2023-03-15 20:15:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 1,258 bytes
コンパイル時間 3,742 ms
コンパイル使用メモリ 232,780 KB
実行使用メモリ 58,032 KB
最終ジャッジ日時 2023-10-18 12:30:00
合計ジャッジ時間 6,018 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 58 ms
40,548 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 48 ms
33,556 KB
testcase_06 AC 85 ms
58,032 KB
testcase_07 AC 13 ms
10,136 KB
testcase_08 AC 27 ms
19,240 KB
testcase_09 AC 64 ms
44,244 KB
testcase_10 AC 71 ms
47,872 KB
testcase_11 AC 70 ms
48,136 KB
testcase_12 AC 80 ms
55,128 KB
testcase_13 AC 21 ms
14,820 KB
testcase_14 AC 37 ms
26,496 KB
testcase_15 AC 60 ms
41,340 KB
testcase_16 AC 49 ms
34,084 KB
testcase_17 AC 51 ms
35,600 KB
testcase_18 AC 73 ms
48,928 KB
testcase_19 AC 60 ms
41,604 KB
testcase_20 AC 27 ms
18,976 KB
testcase_21 AC 63 ms
42,924 KB
testcase_22 AC 37 ms
25,508 KB
testcase_23 AC 85 ms
58,032 KB
testcase_24 AC 86 ms
58,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <math.h>

#include <algorithm>
#include <array>
#include <atcoder/all>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using namespace atcoder;

using Graph = vector<vector<int>>;

using ll = long long;
typedef pair<ll, ll> P_ll;
typedef pair<int, int> P;

const ll INF_ll = 1e17;
const int INF = 1e8;
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;
}
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main() {
  ll P, K;
  cin >> P >> K;
  vector<vector<modint1000000007>> dp(K + 1, vector<modint1000000007>(2, 0));
  dp[0][0] = 1;
  for (int i = 0; i < K; i++) {
    {  //+
      dp[i + 1][0] += dp[i][0];
      dp[i + 1][0] += dp[i][1];

      dp[i + 1][1] += dp[i][1] * (P - 1);
      dp[i + 1][1] += dp[i][0] * (P - 1);
    }
    {  // x
      dp[i + 1][0] += dp[i][0] * P;
      dp[i + 1][0] += dp[i][1];

      dp[i + 1][1] += dp[i][1] * (P - 1);
    }
  }
  cout << dp[K][0].val() << endl;

  return 0;
}
0