CSES - Aalto Competitive Programming 2024 - wk11 - Mon - Results
Submission details
Task:Fibonacci towers
Sender:esya_rae
Submission time:2024-11-18 17:01:59 +0200
Language:Python3 (PyPy3)
Status:READY
Result:
Test results
testverdicttime
#10.07 sdetails
#20.07 sdetails
#30.07 sdetails
#40.07 sdetails
#50.06 sdetails
#60.07 sdetails
#70.07 sdetails
#80.07 sdetails
#90.06 sdetails
#100.06 sdetails
#110.06 sdetails
#120.06 sdetails
#130.07 sdetails
#140.07 sdetails
#150.07 sdetails
#160.06 sdetails
#170.06 sdetails
#180.06 sdetails
#190.07 sdetails
#200.06 sdetails
#210.06 sdetails
#220.07 sdetails
#230.06 sdetails
#240.06 sdetails
#250.06 sdetails
#260.06 sdetails
#270.06 sdetails
#280.07 sdetails
#290.07 sdetails
#300.06 sdetails
#310.07 sdetails
#320.06 sdetails
#330.07 sdetails
#340.06 sdetails
#350.07 sdetails
#360.06 sdetails
#370.06 sdetails
#380.06 sdetails
#390.06 sdetails
#400.07 sdetails
#410.06 sdetails
#420.06 sdetails
#430.07 sdetails
#440.06 sdetails
#450.07 sdetails
#460.07 sdetails
#470.06 sdetails
#480.06 sdetails
#490.06 sdetails
#500.06 sdetails
#510.06 sdetails
#520.06 sdetails
#530.06 sdetails
#540.07 sdetails
#550.07 sdetails
#560.06 sdetails
#570.06 sdetails
#580.06 sdetails
#590.06 sdetails
#600.06 sdetails
#610.06 sdetails
#620.06 sdetails
#630.07 sdetails
#640.07 sdetails
#650.06 sdetails
#660.06 sdetails
#670.06 sdetails
#680.06 sdetails
#690.06 sdetails
#700.07 sdetails
#710.06 sdetails
#720.06 sdetails
#730.06 sdetails
#740.06 sdetails
#750.06 sdetails
#760.06 sdetails
#770.06 sdetails
#780.06 sdetails
#790.06 sdetails
#800.07 sdetails

Code

import sys
import math
import numpy as np

sys.setrecursionlimit(10**6)
input = sys.stdin.readline

mod = 998244353


def fib(a, b):
    fib = []
    for i in range(0, a):
        fib.append(1)
    for i in range(a, b + 1):
        fib.append((fib[-1] + fib[-a]) % mod)
    return fib[b]

def fast_exp(m, n):
    if n == 0:
        return np.identity(m.shape[0], dtype=int)
    g = np.identity(m.shape[0], dtype=int)
    while n > 1:
        if n % 2 == 1:
            g = (g @ m) % mod
            n -= 1
        m = (m @ m) % mod
        n //= 2
    return (m @ g) % mod


def create_f_m(a):
    m = []
    fr = [0] * a
    fr[0], fr[-1] = 1, 1
    m.append(fr)
    for i in range(a - 1):
        r = [0] * a
        r[i] = 1
        m.append(r)
    return np.array(m)



a, b = map(int, input().split())
# a = int(input())

if b < a:
    print(1)
else:
    m = create_f_m(a)
    # print(m)
    fb = fast_exp(m, b - a + 1)
    print(sum(fb[0, :]) % mod)
    # print(fib(a, b % mod))

Test details

Test 1

Verdict:

input
2 10

correct output
89

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 2

Verdict:

input
2 6

correct output
13

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 3

Verdict:

input
2 8

correct output
34

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 4

Verdict:

input
2 68

correct output
977351119

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 5

Verdict:

input
2 78

correct output
20929410

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 6

Verdict:

input
2 76

correct output
878806424

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 7

Verdict:

input
2 485

correct output
908660084

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 8

Verdict:

input
2 519

correct output
838514871

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 9

Verdict:

input
2 602

correct output
892152152

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 10

Verdict:

input
2 165714

correct output
921473843

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 11

Verdict:

input
3 6

correct output
6

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 12

Verdict:

input
3 8

correct output
13

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 13

Verdict:

input
2 7

correct output
21

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 14

Verdict:

input
3 78

correct output
198155624

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 15

Verdict:

input
2 76

correct output
878806424

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 16

Verdict:

input
3 49

correct output
83316385

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 17

Verdict:

input
2 519

correct output
838514871

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 18

Verdict:

input
3 602

correct output
575081686

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 19

Verdict:

input
2 166

correct output
833010588

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 20

Verdict:

input
2 187222

correct output
206734446

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 21

Verdict:

input
2 7

correct output
21

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 22

Verdict:

input
5 8

correct output
5

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 23

Verdict:

input
2 8

correct output
34

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 24

Verdict:

input
5 49

correct output
486716

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 25

Verdict:

input
2 52

correct output
409340464

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 26

Verdict:

input
5 61

correct output
14215310

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 27

Verdict:

input
2 166

correct output
833010588

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 28

Verdict:

input
2 188

correct output
914862760

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 29

Verdict:

input
5 611

correct output
386811672

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 30

Verdict:

input
4 672099

correct output
5039638

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 31

Verdict:

input
77 10

correct output
1

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 32

Verdict:

input
76 1

correct output
1

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 33

Verdict:

input
80 7

correct output
1

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 34

Verdict:

input
72 56

correct output
1

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 35

Verdict:

input
57 97

correct output
42

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 36

Verdict:

input
54 58

correct output
6

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 37

Verdict:

input
50 639

correct output
373574336

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 38

Verdict:

input
58 195

correct output
5403

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 39

Verdict:

input
61 694

correct output
605984493

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 40

Verdict:

input
9 616206422053543989

correct output
952862778

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 41

Verdict:

input
6 169825965437345849

correct output
513277084

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 42

Verdict:

input
5 191867851255868863

correct output
33742481

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 43

Verdict:

input
9 625431978270398522

correct output
737838270

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 44

Verdict:

input
8 688779226095035965

correct output
162344930

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 45

Verdict:

input
10 802140689263714569

correct output
90271065

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 46

Verdict:

input
6 326105735534681902

correct output
815511427

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 47

Verdict:

input
6 714378023239269070

correct output
974264931

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 48

Verdict:

input
8 389060406667759103

correct output
997632165

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 49

Verdict:

input
5 752611790930241374

correct output
663785595

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 50

Verdict:

input
9 616206422053543989

correct output
952862778

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 51

Verdict:

input
9 616206422053543989

correct output
952862778

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 52

Verdict:

input
10 292432805466778024

correct output
54188787

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 53

Verdict:

input
12 877206118126603157

correct output
50978391

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 54

Verdict:

input
15 106209626593822568

correct output
26611817

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 55

Verdict:

input
20 599479100988098599

correct output
119658586

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 56

Verdict:

input
19 751085324932436268

correct output
362164431

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 57

Verdict:

input
13 653792349017119940

correct output
727329363

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 58

Verdict:

input
14 922927469528725341

correct output
702679243

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 59

Verdict:

input
18 278820978471154000

correct output
447470474

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 60

Verdict:

input
19 595145428494262541

correct output
321383191

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 61

Verdict:

input
16 733419934325111819

correct output
603915854

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 62

Verdict:

input
42 977794035917013551

correct output
535001165

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 63

Verdict:

input
46 107297864267805308

correct output
557129508

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 64

Verdict:

input
47 423649320883482177

correct output
894439428

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 65

Verdict:

input
35 923635615021083310

correct output
306200203

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 66

Verdict:

input
27 119042622192684556

correct output
95698341

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 67

Verdict:

input
50 394425873219136058

correct output
461849248

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 68

Verdict:

input
27 702344952743354850

correct output
361328763

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 69

Verdict:

input
34 148052957467783205

correct output
883611228

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 70

Verdict:

input
49 120057477600708020

correct output
411727310

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 71

Verdict:

input
77 985532091144101696

correct output
533259046

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 72

Verdict:

input
76 62568531781086688

correct output
111230040

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 73

Verdict:

input
80 638842883372078079

correct output
843571033

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 74

Verdict:

input
72 568029317340376926

correct output
760917479

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 75

Verdict:

input
57 993363883840818838

correct output
125996687

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 76

Verdict:

input
54 587462523883449402

correct output
707247678

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 77

Verdict:

input
50 654341799647462242

correct output
823275735

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 78

Verdict:

input
58 198843859011456415

correct output
392227014

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 79

Verdict:

input
61 710225245014179861

correct output
352309063

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...

Test 80

Verdict:

input
81 435847411137743327

correct output
639314946

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 3, in <module>
    import...