QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#506843 | #9105. Zayin and Camp | WorldFinalEscaped | WA | 218ms | 238264kb | C++20 | 1.2kb | 2024-08-05 23:13:43 | 2024-08-05 23:13:44 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 30000005;
const int P = 998244353;
#define LL long long
// https://www.cnblogs.com/kyeecccccc/p/16926104.html
struct Mod
{
LL m, p;
void init(int pp) { m = ((__int128)1 << 64) / pp; p = pp; }
LL operator ()(LL x)
{
return x - ((__int128(x) * m) >> 64) * p;
}
} mod;
int fac[N], ifac[N];
inline int qpow(int a, int b = P - 2) {
int res = 1;
while (b) {
if (b & 1) res = mod(1ll * res * a);
a = mod(1ll * a * a);
b >>= 1;
}
return res;
}
inline void init(int n) {
fac[0] = 1;
for (int i = 1; i <= n; i++) fac[i] = mod(1ll * fac[i - 1] * i);
ifac[n] = qpow(fac[n]);
for (int i = n - 1; i >= 0; i--) ifac[i] = mod(1ll * ifac[i + 1] * (i + 1));
}
inline int binom(int n, int m) {
return mod(1ll * mod(1ll * fac[n] * ifac[m]) * ifac[n - m]);
}
int main() {
mod.init(998244353);
init(3e7);
int T; scanf("%d", &T);
while (T--) {
int n, m, r, s;
scanf("%d%d%d%d", &n, &m, &r, &s);
int ans = binom(n * m + s + r + n, n);
ans = mod(1ll * (r + s) * mod(1ll * ans * qpow(n * m + s + r + n)));
printf("%d\n", ans);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 217ms
memory: 238248kb
input:
11 1 10000000 5000000 5000000 10000000 1 5000000 4999999 1 1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 1 2 1 1 2 1 1 1 1 1 2 1 1 1 1 2 65536 128 262144 262144
output:
10000000 918302048 2 72 21602784 953026004 2 5 3 3 592004372
result:
ok 11 lines
Test #2:
score: 0
Accepted
time: 218ms
memory: 238264kb
input:
20 2907 1968 3465570 1924884 3380 2284 2608839 2797776 6426 1284 655387 4698365 5266 1418 2915862 996278 4240 1961 2411930 4535917 6672 326 1907300 3446892 3277 1723 2723016 2513630 3080 1642 4189797 3895123 2742 233 3735134 3357012 3979 1251 2459317 3693129 509 6365 2290345 4638974 8745 615 4764667...
output:
723781999 224712072 750599910 869276921 731158668 895479736 10881753 103229118 690899892 421944632 304404479 579383717 39487740 597221465 958692278 822467061 816115959 120618198 311959114 490554594
result:
ok 20 lines
Test #3:
score: -100
Wrong Answer
time: 213ms
memory: 238132kb
input:
10000 3616 2765 2007646 4250422 1244 8038 1293680 1475945 4244 2356 1988338 2519904 9077 1101 2166961 4557601 7199 1389 1919122 3638263 9201 1086 2695585 641751 6551 1526 3897926 3397577 6805 1469 2840055 1196651 4369 2288 4697877 1629621 1750 5714 4059620 2520142 6405 1561 3929600 3258600 2694 3711...
output:
107534674 346132266 954157595 479052126 380877972 735381985 74839216 405232602 931302260 631564168 712648405 344937670 234651488 869142885 681927263 505369915 564524476 550870911 324659924 66948144 992964548 241231661 484506145 7718309 687385551 973923375 633803608 232509598 278238877 537450623 2945...
result:
wrong answer 4515th lines differ - expected: '39217', found: '998283570'