본문 바로가기

백준1056

[백준] 5751 1 2 3 4 5 6 7 while 1: n=int(input()) if n==0: break tmp=list(map(int, input().split())) mary=tmp.count(0) john=tmp.count(1) print("Mary won %d times and John won %d times"%(mary,john)) cs 이 문제를 조금 더 까다롭게 만들려면 Mary, John 이기는 경우가 1번이면 times 대신 time 으로 출력되게 하면 어떨까.. 하는 생각이 드네요 2021. 3. 19.
[백준] 5235 12345678910import sysfor i in range(int(sys.stdin.readline())): tmp=list(map(int, sys.stdin.readline().split()))[1:] odd,even=0,0 for c in tmp: if c%2==0: even+=c else: odd+=c if even> odd: print("EVEN") elif even==odd :print("TIE") else: print("ODD")Colored by Color Scriptercs 2021. 3. 19.
[백준] 5692 1 2 3 4 5 6 7 8 9 import math import sys while 1: n=sys.stdin.readline().rstrip() if n=='0' : break cnt=0 for i in range(len(n)): cnt+= int(n[i])*math.factorial(len(n)-i) print(cnt) Colored by Color Scripter cs 특이사항은 line 4에 입력을 받을때 처음에는 input()을 썼습니다 문자열로 받을 예정이였으니, 그렇게 하니 시간초과가 나와서 문자열이면 끝에 개행문자 까지 받아서 rstrip() 함수를 사용해야함에도 불구하고 stdin했습니다. 2021. 3. 16.
[백준] 4909 1 2 3 4 5 while 1: tmp=sorted(list(map(int, input().split()))) if sum(tmp)==0 : break if (sum(tmp)-tmp[0]-tmp[5])/4 ==int ((sum(tmp)-tmp[0]-tmp[5])/4): print(int ((sum(tmp)-tmp[0]-tmp[5])/4)) else: print((sum(tmp)-tmp[0]-tmp[5])/4) Colored by Color Scripter cs 2021. 3. 16.
[백준] 4758 1 2 3 4 5 6 7 8 9 10 11 while 1: a,b,c=input().split() a,b,c=float(a),int(b),int(c) if a==0 and b==0 and c==0: break tmp=[] chk=0 if a= 150 and c>=200: tmp.append("Wide Receiver"); chk=1 if a= 300 and c>=500: tmp.append("Lineman"); chk=1 if a= 200 and c>=300: tmp.append("Quarterback"); chk=1 if chk==0 : tmp.append("No positions") print(*tmp) Colored by Color Scripter cs 2021. 3. 16.
[백준] 4714 1 2 3 4 5 while 1: n=float(input()) if n 2021. 3. 16.
[백준] 4635 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import sys while 1: n=int(sys.stdin.readline()) if n==-1: break permile=[] tmptime=[0] time=[] ans=0 for i in range(n): a,b=map(int, sys.stdin.readline().split()) permile.append(a) tmptime.append(b) for i in range(n): time.append(tmptime[i+1]-tmptime[i]) for i in range(n): ans+=permile[i]*time[i] print("%d miles"%ans) cs 2021. 3. 12.
[백준] 20976 1 print(sorted( list(map(int, input().split())))[1]) cs 한줄컷 2021. 3. 12.
[백준] 20673 1 2 3 4 5 p=int(input()) q=int(input()) if p 2021. 3. 12.
[백준] 20499 1 2 3 k,d,a=map(int, input().split('/')) if k+a 2021. 3. 12.
[백준] 3507 1 2 3 ate=int(input()) if ate>198: print(0) else: print(199-ate) cs 2021. 3. 11.
[백준] 2975 1 2 3 4 5 6 7 8 while 1: a,b,c=input().split() a,c=int(a),int(c) if a == 0 and c == 0: break s=a-c if b!='W': s=a+c if s 2021. 3. 11.