Task: | Fibonacci towers |
Sender: | ilyas.ben |
Submission time: | 2024-11-18 16:59:07 +0200 |
Language: | Python3 (PyPy3) |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.04 s | details |
#2 | ACCEPTED | 0.04 s | details |
#3 | ACCEPTED | 0.04 s | details |
#4 | WRONG ANSWER | 0.04 s | details |
#5 | WRONG ANSWER | 0.04 s | details |
#6 | WRONG ANSWER | 0.05 s | details |
#7 | WRONG ANSWER | 0.05 s | details |
#8 | WRONG ANSWER | 0.05 s | details |
#9 | WRONG ANSWER | 0.05 s | details |
#10 | TIME LIMIT EXCEEDED | -- | details |
#11 | ACCEPTED | 0.04 s | details |
#12 | ACCEPTED | 0.04 s | details |
#13 | ACCEPTED | 0.04 s | details |
#14 | WRONG ANSWER | 0.04 s | details |
#15 | WRONG ANSWER | 0.04 s | details |
#16 | ACCEPTED | 0.04 s | details |
#17 | WRONG ANSWER | 0.05 s | details |
#18 | WRONG ANSWER | 0.05 s | details |
#19 | WRONG ANSWER | 0.04 s | details |
#20 | TIME LIMIT EXCEEDED | -- | details |
#21 | ACCEPTED | 0.04 s | details |
#22 | ACCEPTED | 0.04 s | details |
#23 | ACCEPTED | 0.04 s | details |
#24 | ACCEPTED | 0.04 s | details |
#25 | WRONG ANSWER | 0.04 s | details |
#26 | ACCEPTED | 0.04 s | details |
#27 | WRONG ANSWER | 0.05 s | details |
#28 | WRONG ANSWER | 0.04 s | details |
#29 | WRONG ANSWER | 0.04 s | details |
#30 | TIME LIMIT EXCEEDED | -- | details |
#31 | WRONG ANSWER | 0.04 s | details |
#32 | WRONG ANSWER | 0.04 s | details |
#33 | WRONG ANSWER | 0.04 s | details |
#34 | WRONG ANSWER | 0.04 s | details |
#35 | ACCEPTED | 0.04 s | details |
#36 | ACCEPTED | 0.04 s | details |
#37 | WRONG ANSWER | 0.04 s | details |
#38 | ACCEPTED | 0.04 s | details |
#39 | WRONG ANSWER | 0.04 s | details |
#40 | TIME LIMIT EXCEEDED | -- | details |
#41 | TIME LIMIT EXCEEDED | -- | details |
#42 | TIME LIMIT EXCEEDED | -- | details |
#43 | TIME LIMIT EXCEEDED | -- | details |
#44 | TIME LIMIT EXCEEDED | -- | details |
#45 | TIME LIMIT EXCEEDED | -- | details |
#46 | TIME LIMIT EXCEEDED | -- | details |
#47 | TIME LIMIT EXCEEDED | -- | details |
#48 | TIME LIMIT EXCEEDED | -- | details |
#49 | TIME LIMIT EXCEEDED | -- | details |
#50 | TIME LIMIT EXCEEDED | -- | details |
#51 | TIME LIMIT EXCEEDED | -- | details |
#52 | TIME LIMIT EXCEEDED | -- | details |
#53 | TIME LIMIT EXCEEDED | -- | details |
#54 | TIME LIMIT EXCEEDED | -- | details |
#55 | TIME LIMIT EXCEEDED | -- | details |
#56 | TIME LIMIT EXCEEDED | -- | details |
#57 | TIME LIMIT EXCEEDED | -- | details |
#58 | TIME LIMIT EXCEEDED | -- | details |
#59 | TIME LIMIT EXCEEDED | -- | details |
#60 | TIME LIMIT EXCEEDED | -- | details |
#61 | TIME LIMIT EXCEEDED | -- | details |
#62 | TIME LIMIT EXCEEDED | -- | details |
#63 | TIME LIMIT EXCEEDED | -- | details |
#64 | TIME LIMIT EXCEEDED | -- | details |
#65 | TIME LIMIT EXCEEDED | -- | details |
#66 | TIME LIMIT EXCEEDED | -- | details |
#67 | TIME LIMIT EXCEEDED | -- | details |
#68 | TIME LIMIT EXCEEDED | -- | details |
#69 | TIME LIMIT EXCEEDED | -- | details |
#70 | TIME LIMIT EXCEEDED | -- | details |
#71 | TIME LIMIT EXCEEDED | -- | details |
#72 | TIME LIMIT EXCEEDED | -- | details |
#73 | TIME LIMIT EXCEEDED | -- | details |
#74 | TIME LIMIT EXCEEDED | -- | details |
#75 | TIME LIMIT EXCEEDED | -- | details |
#76 | TIME LIMIT EXCEEDED | -- | details |
#77 | TIME LIMIT EXCEEDED | -- | details |
#78 | TIME LIMIT EXCEEDED | -- | details |
#79 | TIME LIMIT EXCEEDED | -- | details |
#80 | TIME LIMIT EXCEEDED | -- | details |
Code
MOD = 10**9 + 7 # Common modulo value for competitive programming def binomial_mod(n, k, mod): """Computes C(n, k) % mod using modular arithmetic.""" if k > n or k < 0: return 0 # Compute combination using modular multiplicative inverse num, den = 1, 1 for i in range(k): num = (num * (n - i)) % mod den = (den * (i + 1)) % mod # Fermat's little theorem for modular multiplicative inverse return (num * pow(den, mod - 2, mod)) % mod def count_towers(a, b): """ Count towers with specific constraints. Args: a (int): Base constraint b (int): Total height constraint Returns: int: Number of possible tower configurations """ if b < a: return 0 result = 0 max_y = b // a # Maximum value for y for y in range(max_y + 1): x = b - a * y if x < 0: break # Compute combinations and accumulate result result = (result + binomial_mod(x + y, x, MOD)) % MOD return result # Example test cases a, b = map(int, input().split()) # Compute and print the result print(count_towers(a, b))
Test details
Test 1
Verdict: ACCEPTED
input |
---|
2 10 |
correct output |
---|
89 |
user output |
---|
89 |
Test 2
Verdict: ACCEPTED
input |
---|
2 6 |
correct output |
---|
13 |
user output |
---|
13 |
Test 3
Verdict: ACCEPTED
input |
---|
2 8 |
correct output |
---|
34 |
user output |
---|
34 |
Test 4
Verdict: WRONG ANSWER
input |
---|
2 68 |
correct output |
---|
977351119 |
user output |
---|
29637311 |
Test 5
Verdict: WRONG ANSWER
input |
---|
2 78 |
correct output |
---|
20929410 |
user output |
---|
923369890 |
Test 6
Verdict: WRONG ANSWER
input |
---|
2 76 |
correct output |
---|
878806424 |
user output |
---|
662189184 |
Test 7
Verdict: WRONG ANSWER
input |
---|
2 485 |
correct output |
---|
908660084 |
user output |
---|
703766125 |
Test 8
Verdict: WRONG ANSWER
input |
---|
2 519 |
correct output |
---|
838514871 |
user output |
---|
850568612 |
Test 9
Verdict: WRONG ANSWER
input |
---|
2 602 |
correct output |
---|
892152152 |
user output |
---|
890352585 |
Test 10
Verdict: TIME LIMIT EXCEEDED
input |
---|
2 165714 |
correct output |
---|
921473843 |
user output |
---|
(empty) |
Test 11
Verdict: ACCEPTED
input |
---|
3 6 |
correct output |
---|
6 |
user output |
---|
6 |
Test 12
Verdict: ACCEPTED
input |
---|
3 8 |
correct output |
---|
13 |
user output |
---|
13 |
Test 13
Verdict: ACCEPTED
input |
---|
2 7 |
correct output |
---|
21 |
user output |
---|
21 |
Test 14
Verdict: WRONG ANSWER
input |
---|
3 78 |
correct output |
---|
198155624 |
user output |
---|
645642280 |
Test 15
Verdict: WRONG ANSWER
input |
---|
2 76 |
correct output |
---|
878806424 |
user output |
---|
662189184 |
Test 16
Verdict: ACCEPTED
input |
---|
3 49 |
correct output |
---|
83316385 |
user output |
---|
83316385 |
Test 17
Verdict: WRONG ANSWER
input |
---|
2 519 |
correct output |
---|
838514871 |
user output |
---|
850568612 |
Test 18
Verdict: WRONG ANSWER
input |
---|
3 602 |
correct output |
---|
575081686 |
user output |
---|
762385055 |
Test 19
Verdict: WRONG ANSWER
input |
---|
2 166 |
correct output |
---|
833010588 |
user output |
---|
379895282 |
Test 20
Verdict: TIME LIMIT EXCEEDED
input |
---|
2 187222 |
correct output |
---|
206734446 |
user output |
---|
(empty) |
Test 21
Verdict: ACCEPTED
input |
---|
2 7 |
correct output |
---|
21 |
user output |
---|
21 |
Test 22
Verdict: ACCEPTED
input |
---|
5 8 |
correct output |
---|
5 |
user output |
---|
5 |
Test 23
Verdict: ACCEPTED
input |
---|
2 8 |
correct output |
---|
34 |
user output |
---|
34 |
Test 24
Verdict: ACCEPTED
input |
---|
5 49 |
correct output |
---|
486716 |
user output |
---|
486716 |
Test 25
Verdict: WRONG ANSWER
input |
---|
2 52 |
correct output |
---|
409340464 |
user output |
---|
316290802 |
Test 26
Verdict: ACCEPTED
input |
---|
5 61 |
correct output |
---|
14215310 |
user output |
---|
14215310 |
Test 27
Verdict: WRONG ANSWER
input |
---|
2 166 |
correct output |
---|
833010588 |
user output |
---|
379895282 |
Test 28
Verdict: WRONG ANSWER
input |
---|
2 188 |
correct output |
---|
914862760 |
user output |
---|
800487427 |
Test 29
Verdict: WRONG ANSWER
input |
---|
5 611 |
correct output |
---|
386811672 |
user output |
---|
414201254 |
Test 30
Verdict: TIME LIMIT EXCEEDED
input |
---|
4 672099 |
correct output |
---|
5039638 |
user output |
---|
(empty) |
Test 31
Verdict: WRONG ANSWER
input |
---|
77 10 |
correct output |
---|
1 |
user output |
---|
0 |
Test 32
Verdict: WRONG ANSWER
input |
---|
76 1 |
correct output |
---|
1 |
user output |
---|
0 |
Test 33
Verdict: WRONG ANSWER
input |
---|
80 7 |
correct output |
---|
1 |
user output |
---|
0 |
Test 34
Verdict: WRONG ANSWER
input |
---|
72 56 |
correct output |
---|
1 |
user output |
---|
0 |
Test 35
Verdict: ACCEPTED
input |
---|
57 97 |
correct output |
---|
42 |
user output |
---|
42 |
Test 36
Verdict: ACCEPTED
input |
---|
54 58 |
correct output |
---|
6 |
user output |
---|
6 |
Test 37
Verdict: WRONG ANSWER
input |
---|
50 639 |
correct output |
---|
373574336 |
user output |
---|
527604188 |
Test 38
Verdict: ACCEPTED
input |
---|
58 195 |
correct output |
---|
5403 |
user output |
---|
5403 |
Test 39
Verdict: WRONG ANSWER
input |
---|
61 694 |
correct output |
---|
605984493 |
user output |
---|
730281750 |
Test 40
Verdict: TIME LIMIT EXCEEDED
input |
---|
9 616206422053543989 |
correct output |
---|
952862778 |
user output |
---|
(empty) |
Test 41
Verdict: TIME LIMIT EXCEEDED
input |
---|
6 169825965437345849 |
correct output |
---|
513277084 |
user output |
---|
(empty) |
Test 42
Verdict: TIME LIMIT EXCEEDED
input |
---|
5 191867851255868863 |
correct output |
---|
33742481 |
user output |
---|
(empty) |
Test 43
Verdict: TIME LIMIT EXCEEDED
input |
---|
9 625431978270398522 |
correct output |
---|
737838270 |
user output |
---|
(empty) |
Test 44
Verdict: TIME LIMIT EXCEEDED
input |
---|
8 688779226095035965 |
correct output |
---|
162344930 |
user output |
---|
(empty) |
Test 45
Verdict: TIME LIMIT EXCEEDED
input |
---|
10 802140689263714569 |
correct output |
---|
90271065 |
user output |
---|
(empty) |
Test 46
Verdict: TIME LIMIT EXCEEDED
input |
---|
6 326105735534681902 |
correct output |
---|
815511427 |
user output |
---|
(empty) |
Test 47
Verdict: TIME LIMIT EXCEEDED
input |
---|
6 714378023239269070 |
correct output |
---|
974264931 |
user output |
---|
(empty) |
Test 48
Verdict: TIME LIMIT EXCEEDED
input |
---|
8 389060406667759103 |
correct output |
---|
997632165 |
user output |
---|
(empty) |
Test 49
Verdict: TIME LIMIT EXCEEDED
input |
---|
5 752611790930241374 |
correct output |
---|
663785595 |
user output |
---|
(empty) |
Test 50
Verdict: TIME LIMIT EXCEEDED
input |
---|
9 616206422053543989 |
correct output |
---|
952862778 |
user output |
---|
(empty) |
Test 51
Verdict: TIME LIMIT EXCEEDED
input |
---|
9 616206422053543989 |
correct output |
---|
952862778 |
user output |
---|
(empty) |
Test 52
Verdict: TIME LIMIT EXCEEDED
input |
---|
10 292432805466778024 |
correct output |
---|
54188787 |
user output |
---|
(empty) |
Test 53
Verdict: TIME LIMIT EXCEEDED
input |
---|
12 877206118126603157 |
correct output |
---|
50978391 |
user output |
---|
(empty) |
Test 54
Verdict: TIME LIMIT EXCEEDED
input |
---|
15 106209626593822568 |
correct output |
---|
26611817 |
user output |
---|
(empty) |
Test 55
Verdict: TIME LIMIT EXCEEDED
input |
---|
20 599479100988098599 |
correct output |
---|
119658586 |
user output |
---|
(empty) |
Test 56
Verdict: TIME LIMIT EXCEEDED
input |
---|
19 751085324932436268 |
correct output |
---|
362164431 |
user output |
---|
(empty) |
Test 57
Verdict: TIME LIMIT EXCEEDED
input |
---|
13 653792349017119940 |
correct output |
---|
727329363 |
user output |
---|
(empty) |
Test 58
Verdict: TIME LIMIT EXCEEDED
input |
---|
14 922927469528725341 |
correct output |
---|
702679243 |
user output |
---|
(empty) |
Test 59
Verdict: TIME LIMIT EXCEEDED
input |
---|
18 278820978471154000 |
correct output |
---|
447470474 |
user output |
---|
(empty) |
Test 60
Verdict: TIME LIMIT EXCEEDED
input |
---|
19 595145428494262541 |
correct output |
---|
321383191 |
user output |
---|
(empty) |
Test 61
Verdict: TIME LIMIT EXCEEDED
input |
---|
16 733419934325111819 |
correct output |
---|
603915854 |
user output |
---|
(empty) |
Test 62
Verdict: TIME LIMIT EXCEEDED
input |
---|
42 977794035917013551 |
correct output |
---|
535001165 |
user output |
---|
(empty) |
Test 63
Verdict: TIME LIMIT EXCEEDED
input |
---|
46 107297864267805308 |
correct output |
---|
557129508 |
user output |
---|
(empty) |
Test 64
Verdict: TIME LIMIT EXCEEDED
input |
---|
47 423649320883482177 |
correct output |
---|
894439428 |
user output |
---|
(empty) |
Test 65
Verdict: TIME LIMIT EXCEEDED
input |
---|
35 923635615021083310 |
correct output |
---|
306200203 |
user output |
---|
(empty) |
Test 66
Verdict: TIME LIMIT EXCEEDED
input |
---|
27 119042622192684556 |
correct output |
---|
95698341 |
user output |
---|
(empty) |
Test 67
Verdict: TIME LIMIT EXCEEDED
input |
---|
50 394425873219136058 |
correct output |
---|
461849248 |
user output |
---|
(empty) |
Test 68
Verdict: TIME LIMIT EXCEEDED
input |
---|
27 702344952743354850 |
correct output |
---|
361328763 |
user output |
---|
(empty) |
Test 69
Verdict: TIME LIMIT EXCEEDED
input |
---|
34 148052957467783205 |
correct output |
---|
883611228 |
user output |
---|
(empty) |
Test 70
Verdict: TIME LIMIT EXCEEDED
input |
---|
49 120057477600708020 |
correct output |
---|
411727310 |
user output |
---|
(empty) |
Test 71
Verdict: TIME LIMIT EXCEEDED
input |
---|
77 985532091144101696 |
correct output |
---|
533259046 |
user output |
---|
(empty) |
Test 72
Verdict: TIME LIMIT EXCEEDED
input |
---|
76 62568531781086688 |
correct output |
---|
111230040 |
user output |
---|
(empty) |
Test 73
Verdict: TIME LIMIT EXCEEDED
input |
---|
80 638842883372078079 |
correct output |
---|
843571033 |
user output |
---|
(empty) |
Test 74
Verdict: TIME LIMIT EXCEEDED
input |
---|
72 568029317340376926 |
correct output |
---|
760917479 |
user output |
---|
(empty) |
Test 75
Verdict: TIME LIMIT EXCEEDED
input |
---|
57 993363883840818838 |
correct output |
---|
125996687 |
user output |
---|
(empty) |
Test 76
Verdict: TIME LIMIT EXCEEDED
input |
---|
54 587462523883449402 |
correct output |
---|
707247678 |
user output |
---|
(empty) |
Test 77
Verdict: TIME LIMIT EXCEEDED
input |
---|
50 654341799647462242 |
correct output |
---|
823275735 |
user output |
---|
(empty) |
Test 78
Verdict: TIME LIMIT EXCEEDED
input |
---|
58 198843859011456415 |
correct output |
---|
392227014 |
user output |
---|
(empty) |
Test 79
Verdict: TIME LIMIT EXCEEDED
input |
---|
61 710225245014179861 |
correct output |
---|
352309063 |
user output |
---|
(empty) |
Test 80
Verdict: TIME LIMIT EXCEEDED
input |
---|
81 435847411137743327 |
correct output |
---|
639314946 |
user output |
---|
(empty) |