結果

問題 No.1049 Zero (Exhaust)
コンテスト
ユーザー rabimea
提出日時 2023-01-25 19:49:57
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 616 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,164 ms
コンパイル使用メモリ 209,104 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-29 09:39:36
合計ジャッジ時間 2,439 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
using vi = vector <int>;
using ll = long long;
using pii = pair <int, int>;
//~ const ll mod = 998244353;
const ll mod = 1e9 + 7;
ll qpow(ll a, ll b, ll m = mod) { ll r = 1, t = a;
	for(; b; b /= 2) { if(b & 1) r = r * t % m; t = t * t % m; } return r; }

int main() {
	ios :: sync_with_stdio(false);
	int n; ll p; cin >> p >> n;
	
	ll a = 1, b = 0;
	for(int i = 0; i < n; i ++) {
		ll c = ((p + 1) * a + 2 * b) % mod;
		ll d = ((p - 1) * a + (2 * p - 2) * b) % mod;
		a = c;
		b = d;
	}
	
	cout << a << '\n';
}
0