結果

問題 No.1049 Zero (Exhaust)
ユーザー izryt(趣味)izryt(趣味)
提出日時 2020-05-28 19:25:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 1,486 bytes
コンパイル時間 904 ms
コンパイル使用メモリ 97,000 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 07:47:52
合計ジャッジ時間 2,170 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 10 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 9 ms
5,376 KB
testcase_06 AC 14 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 6 ms
5,376 KB
testcase_09 AC 10 ms
5,376 KB
testcase_10 AC 11 ms
5,376 KB
testcase_11 AC 12 ms
5,376 KB
testcase_12 AC 13 ms
5,376 KB
testcase_13 AC 5 ms
5,376 KB
testcase_14 AC 7 ms
5,376 KB
testcase_15 AC 11 ms
5,376 KB
testcase_16 AC 9 ms
5,376 KB
testcase_17 AC 9 ms
5,376 KB
testcase_18 AC 12 ms
5,376 KB
testcase_19 AC 11 ms
5,376 KB
testcase_20 AC 6 ms
5,376 KB
testcase_21 AC 11 ms
5,376 KB
testcase_22 AC 7 ms
5,376 KB
testcase_23 AC 14 ms
5,376 KB
testcase_24 AC 14 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <unordered_map>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=r-1;i>=(int)(l);--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;
using ll=long long;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
//int read(){int a;scanf("%lld",&a);return a;}

constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

const int inf = TEN(9) + 10;
const int mod = TEN(9) + 7;

int P, K;
int add[2], mul[2];

signed main()
{
	cin >> P >> K;
	add[0] = 1, mul[0] = 0;
	rep(i, K) {
		int nadd[2] = {0, 0}, nmul[2] = {0, 0};
		int zero = add[0] + mul[0], non_zero = add[1] + mul[1];

		nadd[0] += zero + non_zero;
		nadd[1] += zero * (P - 1) % mod + non_zero * (P - 1) % mod;

		nmul[0] += zero * P % mod + non_zero;
		nmul[1] += non_zero * (P - 1) % mod;

		rep(j, 2) {
			add[j] = nadd[j] % mod;
			mul[j] = nmul[j] % mod;
		}
	}

	int ans = (add[0] + mul[0]) % mod;

	cout << ans << endl;
}

0