提出 #41647634


ソースコード 拡げる

#include <bits/stdc++.h>
#define SZ(x) (int) x.size() - 1
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> void chkmax(T& x, T y) { x = max(x, y); }
template <typename T> void chkmin(T& x, T y) { x = min(x, y); }
template <typename T> void read(T &x) {
	x = 0; int f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
const int N = 3010;
int n, MOD, C[N][N], S[N][N], pw2[N], pw22[N], ans;
int power(int x, int y = MOD - 2) {
	int ans = 1;
	for (; y; x = (ll) x * x % MOD, y >>= 1)
		if (y & 1) ans = (ll) ans * x % MOD;
	return ans;
}
signed main() {
	read(n), read(MOD);
	pw22[0] = pw2[0] = S[0][0] = C[0][0] = 1;
	F(i, 1, n + 1) {
		pw2[i] = (pw2[i - 1] + pw2[i - 1]) % MOD;
		pw22[i] = (pw22[i - 1] + pw22[i - 1]) % (MOD - 1);
		C[i][0] = 1;
		F(j, 1, i)
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD,
			S[i][j] = ((ll) j * S[i - 1][j] + S[i - 1][j - 1]) % MOD;
	}
	F(a, 0, n) {
		int t1 = (ll) C[n][a] * ((a & 1) ? MOD - 1 : 1) % MOD * power(2, pw22[n - a]) % MOD;
		F(b, 0, a) {
			int t2 = (ll) S[a + 1][b + 1] * power(pw2[n - a], b) % MOD;
			// cout << t1 << " " << t2 << " " << (ll) S[a + 1][b + 1] * power(pw2[n - a], b) % MOD << endl;
			ans = (ans + (ll) t1 * t2) % MOD;
		}
	} cout << ans;
	return 0;
}

提出情報

提出日時
問題 E - Everything on It
ユーザ ast123
言語 C++ (GCC 9.2.1)
得点 900
コード長 1594 Byte
結果 AC
実行時間 850 ms
メモリ 58688 KiB

ジャッジ結果

セット名 Sample Subtask1 Subtask2
得点 / 配点 0 / 0 600 / 600 300 / 300
結果
AC × 4
AC × 23
AC × 44
セット名 テストケース
Sample a01, a02, a03, a04
Subtask1 a01, a02, a03, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24
Subtask2 a01, a02, a03, a04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, c25, c26, c27, c28, c29, c30, c31, c32, c33, c34, c35, c36, c37, c38, c39, c40, c41, c42, c43, c44
ケース名 結果 実行時間 メモリ
a01 AC 7 ms 3424 KiB
a02 AC 2 ms 3492 KiB
a03 AC 3 ms 3896 KiB
a04 AC 845 ms 58688 KiB
b05 AC 3 ms 3516 KiB
b06 AC 2 ms 3392 KiB
b07 AC 2 ms 3404 KiB
b08 AC 2 ms 3524 KiB
b09 AC 2 ms 3600 KiB
b10 AC 2 ms 3628 KiB
b11 AC 3 ms 3592 KiB
b12 AC 2 ms 3596 KiB
b13 AC 2 ms 3708 KiB
b14 AC 2 ms 3716 KiB
b15 AC 4 ms 3692 KiB
b16 AC 4 ms 3856 KiB
b17 AC 2 ms 3772 KiB
b18 AC 2 ms 3716 KiB
b19 AC 3 ms 3856 KiB
b20 AC 3 ms 3860 KiB
b21 AC 2 ms 3780 KiB
b22 AC 2 ms 3764 KiB
b23 AC 3 ms 3876 KiB
b24 AC 3 ms 3784 KiB
c25 AC 3 ms 3904 KiB
c26 AC 4 ms 4116 KiB
c27 AC 5 ms 4720 KiB
c28 AC 10 ms 5568 KiB
c29 AC 21 ms 7124 KiB
c30 AC 40 ms 9736 KiB
c31 AC 68 ms 12952 KiB
c32 AC 144 ms 19756 KiB
c33 AC 320 ms 32132 KiB
c34 AC 594 ms 47524 KiB
c35 AC 796 ms 56808 KiB
c36 AC 822 ms 57536 KiB
c37 AC 829 ms 57928 KiB
c38 AC 837 ms 58376 KiB
c39 AC 841 ms 58480 KiB
c40 AC 843 ms 58508 KiB
c41 AC 842 ms 58636 KiB
c42 AC 842 ms 58556 KiB
c43 AC 850 ms 58640 KiB
c44 AC 843 ms 58644 KiB