結果

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

int main() {
    int p, k;
    cin >> p >> k;

    ll s[2] = { 1, 0 };
    for (int i = 0; i < k; i++) {
        ll t[2];
        t[0] = s[0] * (1 + p) + s[1] * 2;
        t[1] = s[0] * (p - 1) + s[1] * (p - 1) * 2;

        for (int h = 0; h < 2; h++) s[h] = t[h] % P;
    }

    cout << s[0] << endl;

    return 0;
}
0