108812024-04-17 14:01:4542Toronyépítés (80 pont)python3Accepted 80/8046ms20472 KiB
from sys import stdin
input=stdin.readline

mod=20210108

def main():
    N=int(input())
    if N<10**5:
        s=[1,3,10]
        for i in range(N):
            s.append((3*s[-1]+s[-2])%mod)
        print(s[N])
        return
    N-=10**5
    if N < 10**5:
        s=[3882421,10070988]
        for i in range(N):
            s.append((3*s[-1]+s[-2])%mod)
        print(s[N])
        return
    N-=10**5
    if N < 10**5:
        s=[1220246,5509401]
        for i in range(N):
            s.append((3*s[-1]+s[-2])%mod)
        print(s[N])
        return
    N-=10**5
    if N < 10**5:
        s=[10010725,15060679]
        for i in range(N):
            s.append((3*s[-1]+s[-2])%mod)
        print(s[N])
        return
    N-=10**5
    if N < 10**5:
        s=[5798169,4533124]
        for i in range(N):
            s.append((3*s[-1]+s[-2])%mod)
        print(s[N])
        return
    N-=10**5
    if N < 10**5:
        s=[19343794,15553821]
        for i in range(N):
            s.append((3*s[-1]+s[-2])%mod)
        print(s[N])
        return
    N-=10**5
    if N < 10**5:
        s=[18277469,4966775]
        for i in range(N):
            s.append((3*s[-1]+s[-2])%mod)
        print(s[N])
        return
    N-=10**5
    if N < 10**5:
        s=[16570697,706364]
        for i in range(N):
            s.append((3*s[-1]+s[-2])%mod)
        print(s[N])
        return
    N-=10**5
    if N < 10**5:
        s=[3045654,4610085]
        for i in range(N):
            s.append((3*s[-1]+s[-2])%mod)
        print(s[N])
        return
    N-=10**5
    s=[1271309,18705807]
    for i in range(N):
        s.append((3*s[-1]+s[-2])%mod)
    print(s[N])
    return

main()
SubtaskSumTestVerdictTimeMemory
base80/80
1Accepted0/017ms11776 KiB
2Accepted0/017ms12144 KiB
3Accepted4/417ms12428 KiB
4Accepted4/417ms12248 KiB
5Accepted5/517ms12564 KiB
6Accepted5/517ms12296 KiB
7Accepted6/646ms20472 KiB
8Accepted6/625ms14784 KiB
9Accepted7/717ms12704 KiB
10Accepted7/718ms13060 KiB
11Accepted8/818ms13260 KiB
12Accepted8/843ms20288 KiB
13Accepted8/839ms19724 KiB
14Accepted8/828ms16376 KiB
15Accepted2/217ms13736 KiB
16Accepted2/217ms13492 KiB