Submission #33272208


Source Code Expand

#include <bits/stdc++.h>

#define eprintf(args...) fprintf(stderr, args)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

using i64 = long long;

const int mxn = 3e5 + 5;
const int mod = 998244353;

inline int qpow(int x, int n) {
	int ans = 1;
	for (; n; n >>= 1, x = 1LL * x * x % mod)
		if (n & 1) ans = 1LL * ans * x % mod;
	return ans;
}

int fac[mxn], ifac[mxn];
std::map <int, std::vector <int> > rem;

inline int comb(int x, int y) {
	if (y < 0 || y > x) return 0;
	if (x < mxn) return 1LL * fac[x] * ifac[y] % mod * ifac[x - y] % mod;
	if ((int) rem[x].size() <= y) {
		for (int i = (int) rem[x].size(); i <= y; ++ i) {
			rem[x].push_back(i ? 1LL * rem[x].back() * (x + mod - i + 1) % mod : 1);
		}
	}
	return 1LL * rem[x][y] * ifac[y] % mod;
}

int n;
i64 K;
int p2[mxn];

int main() {
	rep(i, mxn) fac[i] = i ? 1LL * i * fac[i - 1] % mod : 1;
	ifac[mxn - 1] = qpow(fac[mxn - 1], mod - 2);
	for (int i = mxn - 1; i; -- i) ifac[i - 1] = 1LL * i * ifac[i] % mod;
	rep(i, mxn) p2[i] = i ? 2LL * p2[i - 1] % mod : 1;
	scanf("%d %lld", &n, &K);
	K %= mod;
	int ans = 0;
	for (int i = 0; i <= n; ++ i) {
		int cur = 0;
		cur = (cur + 1LL * (K + 1) * comb(K, n - i)) % mod;
		cur = (cur + mod - 1LL * (n - i) * comb(K + 1, n - i + 1) % mod) % mod;
		ans = (ans + 1LL * comb(n, i) * p2[n - i] % mod * cur) % mod;
	}
	printf("%d\n", ans);
	return 0;
}

Submission Info

Submission Time
Task D - AND OR Equation
User bmb87978
Language C++ (GCC 9.2.1)
Score 700
Code Size 1412 Byte
Status AC
Exec Time 34 ms
Memory 10964 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:41:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   41 |  scanf("%d %lld", &n, &K);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 3
AC × 54
Set Name Test Cases
Sample 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt
All 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt, 02_small_01.txt, 02_small_02.txt, 02_small_03.txt, 02_small_04.txt, 02_small_05.txt, 02_small_06.txt, 02_small_07.txt, 02_small_08.txt, 02_small_09.txt, 02_small_10.txt, 02_small_11.txt, 02_small_12.txt, 02_small_13.txt, 02_small_14.txt, 02_small_15.txt, 02_small_16.txt, 03_rand_01.txt, 03_rand_02.txt, 03_rand_03.txt, 03_rand_04.txt, 03_rand_05.txt, 03_rand_06.txt, 03_rand_07.txt, 03_rand_08.txt, 03_rand_09.txt, 03_rand_10.txt, 04_maxrand_01.txt, 04_maxrand_02.txt, 04_maxrand_03.txt, 04_maxrand_04.txt, 04_maxrand_05.txt, 04_maxrand_06.txt, 04_maxrand_07.txt, 04_maxrand_08.txt, 04_maxrand_09.txt, 04_maxrand_10.txt, 05_small_K_01.txt, 05_small_K_02.txt, 05_small_K_03.txt, 05_small_K_04.txt, 05_small_K_05.txt, 05_small_K_06.txt, 05_small_K_07.txt, 05_small_K_08.txt, 05_small_K_09.txt, 05_small_K_10.txt, 06_near_998244353x_01.txt, 06_near_998244353x_02.txt, 06_near_998244353x_03.txt, 06_near_998244353x_04.txt, 06_near_998244353x_05.txt
Case Name Status Exec Time Memory
01_sample_01.txt AC 12 ms 7100 KiB
01_sample_02.txt AC 13 ms 7184 KiB
01_sample_03.txt AC 14 ms 7060 KiB
02_small_01.txt AC 9 ms 7248 KiB
02_small_02.txt AC 11 ms 7176 KiB
02_small_03.txt AC 11 ms 7052 KiB
02_small_04.txt AC 11 ms 7100 KiB
02_small_05.txt AC 10 ms 7100 KiB
02_small_06.txt AC 14 ms 7176 KiB
02_small_07.txt AC 12 ms 7184 KiB
02_small_08.txt AC 11 ms 7228 KiB
02_small_09.txt AC 11 ms 7116 KiB
02_small_10.txt AC 15 ms 7100 KiB
02_small_11.txt AC 12 ms 7284 KiB
02_small_12.txt AC 11 ms 7056 KiB
02_small_13.txt AC 10 ms 7180 KiB
02_small_14.txt AC 10 ms 7172 KiB
02_small_15.txt AC 10 ms 7100 KiB
02_small_16.txt AC 12 ms 7216 KiB
03_rand_01.txt AC 28 ms 8948 KiB
03_rand_02.txt AC 30 ms 10856 KiB
03_rand_03.txt AC 15 ms 7972 KiB
03_rand_04.txt AC 16 ms 7700 KiB
03_rand_05.txt AC 17 ms 8696 KiB
03_rand_06.txt AC 14 ms 7636 KiB
03_rand_07.txt AC 14 ms 7404 KiB
03_rand_08.txt AC 31 ms 9036 KiB
03_rand_09.txt AC 25 ms 8756 KiB
03_rand_10.txt AC 27 ms 10816 KiB
04_maxrand_01.txt AC 24 ms 10964 KiB
04_maxrand_02.txt AC 30 ms 10812 KiB
04_maxrand_03.txt AC 26 ms 10920 KiB
04_maxrand_04.txt AC 24 ms 10780 KiB
04_maxrand_05.txt AC 33 ms 10920 KiB
04_maxrand_06.txt AC 29 ms 10780 KiB
04_maxrand_07.txt AC 28 ms 10740 KiB
04_maxrand_08.txt AC 28 ms 10776 KiB
04_maxrand_09.txt AC 29 ms 10796 KiB
04_maxrand_10.txt AC 25 ms 10740 KiB
05_small_K_01.txt AC 13 ms 7180 KiB
05_small_K_02.txt AC 14 ms 7052 KiB
05_small_K_03.txt AC 11 ms 7228 KiB
05_small_K_04.txt AC 19 ms 7216 KiB
05_small_K_05.txt AC 14 ms 7180 KiB
05_small_K_06.txt AC 13 ms 7280 KiB
05_small_K_07.txt AC 12 ms 7056 KiB
05_small_K_08.txt AC 18 ms 7280 KiB
05_small_K_09.txt AC 12 ms 7172 KiB
05_small_K_10.txt AC 10 ms 7188 KiB
06_near_998244353x_01.txt AC 34 ms 10848 KiB
06_near_998244353x_02.txt AC 11 ms 7292 KiB
06_near_998244353x_03.txt AC 15 ms 7692 KiB
06_near_998244353x_04.txt AC 23 ms 9016 KiB
06_near_998244353x_05.txt AC 18 ms 8700 KiB