結果
問題 | No.2083 OR Subset |
ユーザー | 👑 ygussany |
提出日時 | 2022-09-17 15:04:27 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 874 ms / 3,000 ms |
コード長 | 887 bytes |
コンパイル時間 | 675 ms |
コンパイル使用メモリ | 30,656 KB |
実行使用メモリ | 196,468 KB |
最終ジャッジ日時 | 2023-08-23 17:46:39 |
合計ジャッジ時間 | 10,063 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 0 ms
4,384 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 464 ms
132,408 KB |
testcase_04 | AC | 237 ms
101,124 KB |
testcase_05 | AC | 838 ms
187,144 KB |
testcase_06 | AC | 211 ms
101,748 KB |
testcase_07 | AC | 19 ms
31,444 KB |
testcase_08 | AC | 30 ms
39,604 KB |
testcase_09 | AC | 452 ms
142,200 KB |
testcase_10 | AC | 278 ms
113,508 KB |
testcase_11 | AC | 159 ms
89,360 KB |
testcase_12 | AC | 98 ms
68,836 KB |
testcase_13 | AC | 866 ms
194,840 KB |
testcase_14 | AC | 838 ms
193,880 KB |
testcase_15 | AC | 854 ms
194,344 KB |
testcase_16 | AC | 874 ms
195,540 KB |
testcase_17 | AC | 869 ms
195,528 KB |
testcase_18 | AC | 1 ms
4,376 KB |
testcase_19 | AC | 862 ms
196,468 KB |
ソースコード
#include <stdio.h> const int Mod = 998244353; long long pow_mod(int n, long long k) { long long N, ans = 1; for (N = n; k > 0; k >>= 1, N = N * N % Mod) if (k & 1) ans = ans * N % Mod; return ans; } int main() { int N; scanf("%d", &N); int i, j, comb[5001][5001]; for (i = 1, comb[0][0] = 1; i <= N; i++) for (j = 1, comb[i][0] = 1, comb[i][i] = 1; j < i; j++) comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % Mod; static int dp[5001][5001], tmp; long long ans = 1; for (j = 1, dp[0][0] = 1; j <= N; j++) dp[0][j] = 0; for (i = 1; i <= N; i++) { tmp = pow_mod(2, i) - i; if (tmp < 0) tmp += Mod; for (j = 0; j < i; j++) dp[i][j] = 0; for (; j <= N; j++) { dp[i][j] = (dp[i-1][j-1] + (long long)i * dp[i][j-1]) % Mod; ans += (long long)dp[i][j] * comb[N][j] % Mod * pow_mod(tmp, N - j) % Mod; } } printf("%lld\n", ans % Mod); fflush(stdout); return 0; }