목록문제/백준_파이썬 (155)
sm 기술 블로그
import sys input = sys.stdin.readline N = int(input()) paper = [[0]*101 for _ in range(101)] for _ in range(N): x,y = map(int, input().split()) for a in range(10): for b in range(10): paper[x+a][y+b] = 1 sum = 0 for i in paper : sum += i.count(1) print(sum) 간단히 0으로 종이 전체를 그리고, 10*10만큼 1로 바꾸고 겹치는 부분은 덮어 버린다. 전체의 종이에서 1의 개수를 세어준다.
import sys input = sys.stdin.readline score = {"A+":4.5,"A0":4.0,"B+":3.5,"B0":3.0,"C+":2.5,"C0":2.0,"D+":1.5,"D0":1.0,"F":0.0,"P":-1} subject = [list(input().split()) for i in range(20)] sum = 0.0 totalHakJum = 0.0 for i in range(20): if score[subject[i][2]] == -1: continue else: totalHakJum += float(subject[i][1]) sum += (float(subject[i][1]) * score[subject[i][2]]) print(format(sum / totalHak..
import sys input = sys.stdin.readline N = int(input()) star = (N*2)-1 N = star//2 + 1 starStack = list() for i in range(1, N+1): if i < N: blank = star-(i*2-1) tmp = ((blank//2) * " ") + ((star-blank) * "*") print(tmp) starStack.append(tmp) else: print(star * "*") for j in range(len(starStack)): print(starStack.pop()) 별찍기 - 스택 이용
import sys input = sys.stdin.readline N = int(input()) board = list(input().split()) M = int(input()) dp = [[0]*N for _ in range(N)] result = [] for i in range(N): dp[i][i] = 1 for i in range(N-1): if board[i] == board[i+1]: dp[i][i+1] = 1 for i in range(2, N): for j in range(N-i): if board[j] == board[i+j] and dp[j+1][i+j-1] == 1: dp[j][i+j] = 1 for i in range(M): S, E = map(int, input().split(..