QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#878103#8479. Simple Math ProblemkangkunmaAC ✓331ms17024kbPython3241b2025-02-01 13:34:182025-02-01 13:34:19

Judging History

This is the latest submission verdict.

  • [2025-02-01 13:34:19]
  • Judged
  • Verdict: AC
  • Time: 331ms
  • Memory: 17024kb
  • [2025-02-01 13:34:18]
  • Submitted

answer

P=[1];M=998244353
for i in range(2*10**5+5):P+=[P[-1]*((i+2)//2)%M]
from sys import stdin
for i in range(int(input())):
    m,n=map(int,stdin.readline().split())
    if n>m:m,n=n,m
    print(P[n+m+1]*pow(P[n+1]*P[m],-1,M)*((n+2)//2)%M)

詳細信息

Test #1:

score: 100
Accepted
time: 56ms
memory: 16896kb

input:

2
1 9
2 6

output:

30
80

result:

ok 2 number(s): "30 80"

Test #2:

score: 0
Accepted
time: 59ms
memory: 16896kb

input:

10
1 9
7 6
2 4
7 8
1 3
10 10
5 3
7 6
1 10
6 6

output:

30
4900
36
19600
6
698544
120
4900
36
2800

result:

ok 10 numbers

Test #3:

score: 0
Accepted
time: 57ms
memory: 16896kb

input:

100
82 51
81 14
37 17
78 92
64 15
8 86
89 8
87 77
66 10
15 12
100 25
92 47
21 78
20 63
13 49
41 36
41 79
16 87
87 69
3 76
80 60
100 49
70 59
72 8
38 71
45 97
71 14
76 54
81 4
59 46
39 29
92 3
49 22
53 99
59 52
74 31
92 43
42 23
44 9
82 47
7 40
12 9
3 55
37 85
46 22
84 52
98 41
21 77
63 17
62 91
64 4...

output:

752899708
446565499
278687685
144416603
506797926
759899063
666445801
98608251
165916617
72144072
903290137
463404123
70644785
574203634
358013808
498835300
418752526
364112873
303009183
1216800
75603736
2984167
935632614
39603021
696685107
130630731
145418920
380888713
33431769
757001953
281957647
...

result:

ok 100 numbers

Test #4:

score: 0
Accepted
time: 58ms
memory: 16896kb

input:

1000
89 983
751 38
201 34
39 841
873 453
65 674
216 560
644 914
345 670
518 622
938 583
719 137
78 359
860 448
907 741
629 236
549 893
999 844
345 63
66 320
723 990
467 215
24 665
756 682
604 853
160 262
30 153
31 278
631 232
360 495
519 347
906 259
992 541
33 167
233 661
720 908
332 55
153 17
376 5...

output:

256821649
108828689
839314530
149279492
272328680
890678506
997526709
278154808
201068094
533190928
139201095
739204158
325508945
971727575
903249760
471141773
578369045
260667601
438467088
355143014
578146298
477003459
878980475
925370887
941969422
761671373
92304831
245794313
854972335
306947768
1...

result:

ok 1000 numbers

Test #5:

score: 0
Accepted
time: 84ms
memory: 16768kb

input:

10000
5880 5988
2292 4026
3420 3246
5243 41
4223 468
682 5008
1497 584
1573 7049
5848 4129
5555 9957
9311 7225
6065 9498
3569 1695
717 1968
9690 7557
8700 9427
5142 371
8788 2260
9576 2674
4322 7448
5829 9123
982 7591
438 1590
9459 5982
5002 243
4144 4254
9585 9988
6745 3691
9602 2297
9518 1181
9814...

output:

317637488
14444410
655372169
675113924
687231175
920170546
496064013
38609038
843578075
817055202
193722470
710960763
307750403
836111887
681812722
44826841
758533749
301604129
820896982
747525452
941036053
758574633
807816162
969362451
332275820
917480290
308280003
976133341
171510212
205836718
673...

result:

ok 10000 numbers

Test #6:

score: 0
Accepted
time: 331ms
memory: 17024kb

input:

100000
13036 23902
71466 9482
98728 78471
22915 2470
5999 53211
25994 3996
11349 30511
56448 17277
78308 18316
42069 38636
63127 26256
63985 57249
58305 64366
17839 28518
18980 95945
36316 6076
69530 96509
6940 6039
56048 41847
82118 41054
49670 95896
45891 74636
90736 75413
27251 87730
68344 66202
...

output:

277985833
956007429
624794586
362566497
910799081
912677925
389672091
724746099
498912590
922116302
81430565
325940170
135648675
643600322
878131268
760224616
253216165
873156200
884923790
934964389
431107651
711595921
954666707
553135956
570568311
954285119
796732848
357788157
551398688
633037510
3...

result:

ok 100000 numbers