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

while True: a = int(input()) if a == 0: break print(int(a*(a+1)/2)) 참 오랜만에 푼 문제이다... 정말 쉬운 문제이다. 피라미드를 쌓는데에 윗칸부터 {1, 2, 3, 4, ..., n-2, n-1, n} 개의 블록이 쓰일 것이므로 공차가 1인 등차수열의 합 공식을 사용하여 문제를 풀어 주면 된다.

from collections import Counter;print(Counter(sorted([input() for i in range(int(input()))])).most_common()[0][0])

n, m = map(int, input().split()) book = [] for i in range(n): book.append(input()) for i in range(len(book)): if book[i][0] == "

alljobs = set([input() for i in range(int(input()))]) alreadydid = set([input() for i in range(int(input()))]) print(len(alljobs-alreadydid)) [print(x) for x in list(alljobs-alreadydid)]

n, m = map(int,input().split()) l = [[int(x[0]), int(x[1]), x[2]] for x in [input().split() for i in range(m)]] for i in range(max([x[1] for x in l])+1): toPrint = sorted([x for x in l if x[1]==i], key=lambda x:x[0]) if toPrint!=[]: for j in toPrint: print(j[-1],end="")

a,b,c = int(input()), int(input()), int(input()) if a==b==c: print("Equilateral") elif a==b or b==c or c==a: print("Isosceles") else: if a+b+c==180: print("Scalene") else: print("Error")

tensyu = [0, 0, 0] santen = [0, 0, 0] niten = [0, 0, 0] for i in range(int(input())): a = list(map(int, input().split())) tensyu[0] += a[0] tensyu[1] += a[1] tensyu[2] += a[2] if a[0] == 3: santen[0] += 1 elif a[1] == 3: santen[1] += 1 else: santen[2] += 1 if a[0] == 2: niten[0] += 1 elif a[1] == 2: niten[1] += 1 else: niten[2] += 1 #print(tensyu, santen, niten) if len(set(tensyu)) == len(tensyu..

n, k = map(int, input().split()) coins = [int(input()) for x in range(n)] ans = 0 for i in list(reversed(coins)): if k < i: continue coin = 1 while True: if k-(i*coin) < i: k -= i*coin break coin += 1 ans += coin print(ans) 간단한 그리디 알고리즘(탐욕법) 문제이다.