96582024-02-23 18:12:59NagyLeoToronyépítés (1,1,3,3)pypy3Accepted 50/5061ms88424 KiB
import sys

sys.setrecursionlimit(10**9)

memo={}

def main2():
    N = int(input())

    def torony(magassag):
        if magassag == 0:
            return 0
        if magassag == 1:
            return 2
        if magassag == 2:
            return 4
        if magassag == 3:
            return 8+2
        if magassag in memo:
            return memo[magassag]
        res=0
        res += 2*torony(magassag-1)
        if magassag >= 3:
            res += 2*torony(magassag - 3)
        memo[magassag]=res%20210108
        return res%20210108

    print(torony(N))

#main2()

def main():

    N = int(input())

    if N == 0:
        return 0
    if N == 1:
        return 2
    if N == 2:
        return 4
    if N == 3:
        return 8+2
    a,b,c=2,4,10
    for i in range(N-3):
        # 2 ,4 ,10 , ?
        # 2*10+2*2=24
        a,b,c=b,c,(2*c+2*a)%20210108
    return c

print(main())
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/048ms76572 KiB
2Accepted0/050ms85420 KiB
3Accepted3/339ms76684 KiB
4Accepted3/346ms77300 KiB
5Accepted4/443ms77368 KiB
6Accepted4/439ms77968 KiB
7Accepted4/461ms86860 KiB
8Accepted4/450ms86424 KiB
9Accepted4/439ms78128 KiB
10Accepted4/446ms78084 KiB
11Accepted4/450ms87248 KiB
12Accepted4/452ms87600 KiB
13Accepted4/461ms88080 KiB
14Accepted4/452ms88424 KiB
15Accepted2/239ms79048 KiB
16Accepted2/239ms79252 KiB