96572024-02-23 18:12:12NagyLeoToronyépítés (1,1,3,3)python3Time limit exceeded 38/50234ms13220 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
base38/50
1Accepted0/017ms11432 KiB
2Accepted0/018ms11780 KiB
3Accepted3/317ms11708 KiB
4Accepted3/318ms12108 KiB
5Accepted4/417ms12140 KiB
6Accepted4/417ms12316 KiB
7Time limit exceeded0/4234ms12384 KiB
8Accepted4/445ms12532 KiB
9Accepted4/417ms12548 KiB
10Accepted4/417ms12360 KiB
11Accepted4/461ms12792 KiB
12Time limit exceeded0/4231ms12940 KiB
13Time limit exceeded0/4208ms13220 KiB
14Accepted4/490ms13096 KiB
15Accepted2/217ms13008 KiB
16Accepted2/217ms13128 KiB