96552024-02-23 18:05:34NagyLeoToronyépítés (1,1,3,3)python3Runtime error 26/5052ms68124 KiB
import sys

sys.setrecursionlimit(10**9)

memo={}

def main():
    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))

main()
SubtaskSumTestVerdictTimeMemory
base26/50
1Accepted0/018ms11216 KiB
2Accepted0/023ms15860 KiB
3Accepted3/317ms11876 KiB
4Accepted3/317ms11864 KiB
5Accepted4/417ms12540 KiB
6Accepted4/417ms12364 KiB
7Runtime error0/450ms68124 KiB
8Runtime error0/452ms68036 KiB
9Accepted4/418ms12896 KiB
10Accepted4/417ms13248 KiB
11Runtime error0/452ms67528 KiB
12Runtime error0/448ms67592 KiB
13Runtime error0/448ms67312 KiB
14Runtime error0/446ms67492 KiB
15Accepted2/218ms13020 KiB
16Accepted2/217ms13400 KiB