結果

問題 No.1100 Boxes
ユーザー e869120e869120
提出日時 2020-06-26 22:34:07
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 185 ms / 2,000 ms
コード長 1,167 bytes
コンパイル時間 525 ms
コンパイル使用メモリ 64,468 KB
実行使用メモリ 8,508 KB
最終ジャッジ日時 2023-09-18 06:00:25
合計ジャッジ時間 7,224 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
8,232 KB
testcase_01 AC 103 ms
8,288 KB
testcase_02 AC 102 ms
8,412 KB
testcase_03 AC 102 ms
8,244 KB
testcase_04 AC 103 ms
8,224 KB
testcase_05 AC 103 ms
8,232 KB
testcase_06 AC 102 ms
8,240 KB
testcase_07 AC 102 ms
8,232 KB
testcase_08 AC 102 ms
8,412 KB
testcase_09 AC 102 ms
8,508 KB
testcase_10 AC 103 ms
8,228 KB
testcase_11 AC 103 ms
8,348 KB
testcase_12 AC 102 ms
8,292 KB
testcase_13 AC 103 ms
8,280 KB
testcase_14 AC 101 ms
8,236 KB
testcase_15 AC 102 ms
8,236 KB
testcase_16 AC 103 ms
8,232 KB
testcase_17 AC 104 ms
8,240 KB
testcase_18 AC 104 ms
8,224 KB
testcase_19 AC 106 ms
8,236 KB
testcase_20 AC 110 ms
8,412 KB
testcase_21 AC 134 ms
8,244 KB
testcase_22 AC 167 ms
8,284 KB
testcase_23 AC 131 ms
8,340 KB
testcase_24 AC 142 ms
8,288 KB
testcase_25 AC 147 ms
8,244 KB
testcase_26 AC 181 ms
8,292 KB
testcase_27 AC 166 ms
8,224 KB
testcase_28 AC 120 ms
8,272 KB
testcase_29 AC 174 ms
8,224 KB
testcase_30 AC 161 ms
8,284 KB
testcase_31 AC 130 ms
8,284 KB
testcase_32 AC 155 ms
8,416 KB
testcase_33 AC 185 ms
8,268 KB
testcase_34 AC 183 ms
8,336 KB
testcase_35 AC 103 ms
8,300 KB
testcase_36 AC 177 ms
8,244 KB
testcase_37 AC 103 ms
8,284 KB
testcase_38 AC 135 ms
8,228 KB
testcase_39 AC 173 ms
8,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 32; i++) {
		if ((b / (1LL << i)) % 2 == 1) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}

long long Div(long long a, long long b, long long m) {
	return (a * modpow(b, m - 2, m)) % m;
}

long long mod = 998244353;
long long N, K, power[1 << 18];
long long fact[1 << 18], inv[1 << 18];

void init() {
	fact[0] = 1; power[0] = 1;
	for (int i = 1; i <= 100000; i++) fact[i] = (1LL * i * fact[i - 1]) % mod;
	for (int i = 0; i <= 100000; i++) inv[i] = Div(1, fact[i], mod);
	for (int i = 1; i <= 100000; i++) power[i] = (2LL * power[i - 1]) % mod;
}

long long ncr(int n, int r) {
	if (n < r || r < 0) return 0;
	return (fact[n] * inv[r] % mod) * inv[n - r] % mod;
}

int main() {
	init(); cin >> N >> K;

	long long ret = 0;
	for (int i = K - 1; i >= 1; i--) {
		long long a1 = power[(K - 1) - i]; if (((K - 1) - i) % 2 == 1) a1 *= -1LL;
		long long a2 = ncr(K, i);
		long long a3 = modpow(i, N, mod);
		ret += (1LL * a1 * a2 % mod) * a3 % mod;
		ret = (ret + mod * mod) % mod;
	}
	cout << ret << endl;
	return 0;
}
0