QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#506850#9105. Zayin and CampWorldFinalEscapedAC ✓235ms238316kbC++201018b2024-08-05 23:21:452024-08-05 23:21:46

Judging History

你现在查看的是最新测评结果

  • [2024-08-05 23:21:46]
  • 评测
  • 测评结果:AC
  • 用时:235ms
  • 内存:238316kb
  • [2024-08-05 23:21:45]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int N = 30000005;
const int P = 998244353;

#define ll long long
#define ld long double


int fac[N], ifac[N];
inline int qpow(int a, int b = P - 2) {
    int res = 1;
    while (b) {
        if (b & 1) res = 1ull * res * a % P;
        a = 1ull * a * a % P;
        b >>= 1;
    }
    return res;
}
inline void init(int n) {
    fac[0] = 1;
    for (int i = 1; i <= n; i++) fac[i] = 1ull * fac[i - 1] * i % P;
    ifac[n] = qpow(fac[n]);
    for (int i = n - 1; i >= 0; i--) ifac[i] = 1ull * ifac[i + 1] * (i + 1) % P;
}
inline int binom(int n, int m) {
    return 1ll * fac[n] * ifac[m] % P * ifac[n - m] % P;

}

int main() {
    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 = 1ll * (r + s) * ans % P * qpow(n * m + s + r + n) % P;
        printf("%d\n", ans);
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 213ms
memory: 238184kb

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: 231ms
memory: 238316kb

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: 0
Accepted
time: 235ms
memory: 238244kb

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:

ok 10000 lines

Test #4:

score: 0
Accepted
time: 231ms
memory: 238168kb

input:

10000
7 1428571 3806892 3971042
5 2000000 4338289 3148090
10 1000000 3147757 839143
8 1250000 2881455 2205039
7 1428571 2342154 2438676
3 3333333 4761187 1403114
6 1666666 330504 4140769
10 1000000 3487237 481616
1 10000000 4151782 2903821
7 1428571 2563975 3328818
1 10000000 280373 4740202
7 142857...

output:

435423871
845483986
674931684
504892305
286485841
703694039
744671270
385181425
7055603
173023557
5020575
807367718
543219467
876429046
354148931
6258348
61989990
103151853
560409410
713566565
515717026
500365288
604358913
346711004
542709460
364374860
308185404
486425107
950251013
241967180
6427206...

result:

ok 10000 lines

Test #5:

score: 0
Accepted
time: 235ms
memory: 238248kb

input:

10000
2000000 5 234997 359032
3333333 3 3480239 397877
1428571 7 1764822 2280539
3333333 3 4283465 4449809
1428571 7 2479124 2105713
2500000 4 257363 4964607
2500000 4 210476 32336
1428571 7 3535190 64528
3333333 3 1796295 3979453
10000000 1 1300527 3139051
1111111 9 1857103 4546029
10000000 1 43260...

output:

601808266
519466734
979400098
312889390
88051123
853842460
381243056
709326067
327087381
877914126
582716530
126896771
113580723
988870074
645021596
389233843
154044915
846240727
492062144
476093414
480656293
850772851
101475207
790985572
893502279
229118932
548588503
441033211
44427859
972364425
12...

result:

ok 10000 lines