結果

問題 No.1049 Zero (Exhaust)
ユーザー nanophoto12nanophoto12
提出日時 2020-05-09 11:32:50
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 816 bytes
コンパイル時間 1,949 ms
コンパイル使用メモリ 202,364 KB
実行使用メモリ 18,680 KB
最終ジャッジ日時 2023-09-18 18:42:42
合計ジャッジ時間 3,133 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 12 ms
13,680 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 10 ms
11,868 KB
testcase_06 AC 15 ms
18,476 KB
testcase_07 AC 4 ms
4,804 KB
testcase_08 AC 6 ms
7,712 KB
testcase_09 AC 13 ms
14,680 KB
testcase_10 AC 13 ms
15,992 KB
testcase_11 AC 14 ms
15,628 KB
testcase_12 AC 15 ms
17,852 KB
testcase_13 AC 6 ms
6,612 KB
testcase_14 AC 8 ms
9,928 KB
testcase_15 AC 11 ms
13,772 KB
testcase_16 AC 10 ms
12,104 KB
testcase_17 AC 10 ms
12,176 KB
testcase_18 AC 13 ms
16,304 KB
testcase_19 AC 11 ms
14,036 KB
testcase_20 AC 7 ms
7,636 KB
testcase_21 AC 12 ms
14,320 KB
testcase_22 AC 8 ms
9,340 KB
testcase_23 AC 15 ms
18,656 KB
testcase_24 AC 16 ms
18,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

#include <bits/stdc++.h>
using namespace std;

const ll mod = 1e9 + 7;

const ll INF = 1e15;

int main() {
	ll p, k;
	cin >> p >> k;
	vector<ll> as;
	vector<ll> bs;
	as.reserve(k + 1);
	bs.reserve(k + 1);
	as.push_back(1);
	bs.push_back(0);
	rep(i, k) {
		auto a = (p + 1) * as.back() + 2 * (p - 1) * bs.back();
		a %= mod;
		auto b = as.back() + 2 * (p - 1) * bs.back();
		b %= mod;
		as.push_back(a);
		bs.push_back(b);
	}
	cout << as.back() << endl;
	return 0;
}
0