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

test_case = [] for i in range(int(input())): test_case.append(list(map(int, input().split(",")))) for i in test_case: print(sum(i)) 11022번 푸는 풀이에서 3번째 줄까지 가져왔다.

def is_prime(n): if n == 1: return False for i in range(2, n): if n % i == 0: return False return True divisor = [] summ = 0 m = int(input()) n = int(input()) for i in range(m, n+1): if is_prime(i): summ += i divisor.append(i) if len(divisor) == 0: print(-1) else: print(summ) print(divisor[0]) is_prime 함수는 이전 글에서 가져왔다. https://developer-next-to-you.tistory.com/136 [Python] 백준 1929번(소수 구하기) 문제 풀이..

n = int(input()) a = False for i in range(1, n): hihi = i + sum(list(map(int, str(i)))) if hihi == n: print(i) a = True break if a == False: print(0) 내가 예전에 내가 왜 hihi라는 변수명을 쓰는지 올린 적이 있었던 것 같다. https://developer-next-to-you.tistory.com/70 [Python] 백준 2475번(검증수) 문제 풀이 numbers = list(map(int, input().split())) hihi = 0 for number in numbers: hihi += number ** 2 print(hihi % 10) 고유번호 5자리를 입력받은 후, 그..

문제가 정말 길다. sequence = [] for i in range(int(input())): sequence.append(int(input())) if sequence[1] - sequence[0] == sequence[2] - sequence[1]: print(sequence[-1]+(sequence[1]-sequence[0])) else: print(int(sequence[-1]*(sequence[1]/sequence[0]))) 문제에서는 등차수열과 등비수열 둘 중 하나를 주기 때문에 등차수열이 아니라면 등비수열이다.

어디가? numbers = [] while True: a = list(map(int, input().split())) if a == [0, 0]: break numbers.append(a) for number in numbers: if number[0] > number[1]: print("Yes") continue print("No")

test_case = [] for i in range(int(input())): test_case.append(list(map(int, input().split()))) for i in range(1, len(test_case)+1): print("Case #" + str(i) + ":", test_case[i-1][0], "+", test_case[i-1][1], "=", sum(test_case[i-1]))

test_case = [] while True: a = input() if a == "#": break test_case.append(list("".join(list(a.lower())))) for i in test_case: print(i.count("a") + i.count("i") + i.count("u") + i.count("e") + i.count("o")) 일본에서는 아에이오우를 아이우에오 라고 한다. 어쩌다 보니 아이우에오 라고 쓴 나 자신을 발견했다.