Algorithm/goorm
goorm 소수 판별, 고장난 컴퓨터, 하노이의 탑
마띠(쥔장)
2020. 9. 13. 15:05
# -*- coding: utf-8 -*-
# UTF-8 encoding when using korean
n = int(input())
sw = 0
for i in range(2, n):
if(n % i == 0):
sw += 1
if(sw == 0):
print("True")
else:
print("False")
# -*- coding: utf-8 -*-
# UTF-8 encoding when using korean
n, tick = map(int, input().split(' '))
num = input().split(' ')
cnt = 0
for i in range(0, n-1):
if((int(num[i+1]) - int(num[i])) > tick):
cnt = 0
else:
cnt += 1
print(cnt + 1)
# -*- coding: utf-8 -*-
# UTF-8 encoding when using korean
cnt = 0
def Hanoi(n, de, tmp, a):
global cnt
if(n == 1):
cnt += 1
else:
Hanoi(n - 1, de, a, tmp)
cnt += 1
Hanoi(n - 1, tmp, de, a)
return cnt
if __name__ == "__main__":
n = int(input())
Hanoi(n, '1st', '2nd', '3rd')
print(cnt)
728x90