목록PS/Python (269)
지나가던 개발자

import math s = input() t = input() if s*(math.lcm(len(s), len(t))//len(s)) == t*(math.lcm(len(s), len(t))//len(t)): print(1) else: print(0) f(s) == f(t)가 참임을 판별하려면 s와 t를 같은 길이로 만든 뒤 둘이 같은지 다른지 여부를 판별하면 된다.

for i in range(int(input())): s, p = input().split() print(len(s.replace(p, "아")))

w = input() for i in range(len(w)//10+1): for j in range(i*10, (i+1)*10): try: print(w[j], end="") except: break print("")

n = int(input()) if n < 3: if n == 0: print(0) else: print(1) else: f1 = 1 f2 = 1 for i in range(n-2): f2 += f1 f1 = f2 - f1 print(f2) n이 0 혹은 1의 수가 될 수 있음을 모르고 헤매다가 문제 읽고 알았다..

while True: pages = [False for i in range(int(input()))] if len(pages) == 0: break toPrint = input().split(",") for i in toPrint: to_print = list(map(int, i.split("-"))) if to_print[0] > len(pages): continue if len(to_print) == 1: pages[to_print[0]-1] = True continue if to_print[0] > to_print[1]: continue if to_print[1] > len(pages): to_print[1] = len(pages) for j in range(to_print[0], to_print[..

from itertools import permutations def is_palindrome(a): return a == a[::-1] for i in range(int(input())): tango = [] for j in range(int(input())): tango.append(input()) printed = False for j in permutations(tango, 2): if is_palindrome("".join(j)): printed = True print("".join(j)) break if not printed: print(0) 메모리 초과가 떠도 그닥 이상치 않다고 생각하고 있었는데 맞았다.

print(len(input().replace("c=", "크").replace("c-", "로").replace("dz=", "아").replace("d-", "티").replace("lj", "아").replace("nj", "알").replace("s=", "파").replace("z=", "벳"))) 반복문을 사용해서 매우 귀찮게 구현할 수도 있다. i번째 요소와 i+1번째 요소를 비교해서 크로아티아 알파벳에 해당되면 i+1번째 요소를 지우고 length += 1을 해주는 뭐 그런 식으로 말이다. 그런데 이미 내장 함수 만드는 분들이 다 구현해 놓은 게 있는데 굳이 그렇게 해야 할까?

for i in range(int(input())): print("Class", i+1) classI = sorted(list(map(int, input().split()))[1:]) print("Max", str(max(classI)) + ", Min", min(classI), end=", ") largestGap = 0 for j in range(len(classI)-1): if classI[j+1] - classI[j] > largestGap: largestGap = classI[j+1] - classI[j] print("Largest gap", largestGap) 자꾸 틀렸습니다 떠서 "뭐지...?" 이러고 코드 살폈는데 맨 마지막 줄에 "Largest gap"을 "Largest Gap"이라고 ..