108812024-04-17 14:01:4542Toronyépítés (80 pont)python3Elfogadva 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()
RészfeladatÖsszpontTesztVerdiktIdőMemória
base80/80
1Elfogadva0/017ms11776 KiB
2Elfogadva0/017ms12144 KiB
3Elfogadva4/417ms12428 KiB
4Elfogadva4/417ms12248 KiB
5Elfogadva5/517ms12564 KiB
6Elfogadva5/517ms12296 KiB
7Elfogadva6/646ms20472 KiB
8Elfogadva6/625ms14784 KiB
9Elfogadva7/717ms12704 KiB
10Elfogadva7/718ms13060 KiB
11Elfogadva8/818ms13260 KiB
12Elfogadva8/843ms20288 KiB
13Elfogadva8/839ms19724 KiB
14Elfogadva8/828ms16376 KiB
15Elfogadva2/217ms13736 KiB
16Elfogadva2/217ms13492 KiB