본문 바로가기

python-algorithm1402

[백준] 4493 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 import sys n=int(sys.stdin.readline()) for _ in range(n): a=int(sys.stdin.readline()) cnt1=0 cnt2=0 for i in range(a): p1,p2=sys.stdin.readline().split() if p1=='R': if p2=='P':cnt2+=1 elif p2=='S':cnt1+=1 if p1 == 'P': if p2 == 'R': cnt1 += 1 elif p2 == 'S': cnt2 += 1 if p1=='S': if p2=='P':cnt1+=1 elif p2=='R':cnt2+=1 if cnt1>cnt2: print.. 2020. 12. 23.
[백준] 4101 1 2 3 4 5 6 7 import sys while True: a,b =map(int, sys.stdin.readline().split()) if a==0 and b==0: exit() else: if a>b: print("Yes") else : print("No") cs 2020. 12. 23.
[백준] 3486 1 2 3 4 5 6 7 for _ in range(int(input())): a,b=map(str, input().split()) ans=int(str(a)[::-1])+int(str(b)[::-1]) while ans%10 ==0: ans=ans/10 ans=int(ans) print(str(ans)[::-1]) cs 백준 문제를 난이도 낮은 순부터 풀고 있는데 전부 다 풀기엔 시간이 걸릴것같아 한글로 된 문제부터 풀자고 생각했는데 어쩌다 풀게 됐습니다. 2020. 12. 23.
[백준] 3460 1 2 3 4 5 6 7 8 9 10 11 12 import sys t=int(sys.stdin.readline()) for _ in range(t): n=int(sys.stdin.readline()) tmp=[] while n//2!=0: tmp.append(n%2) n=n//2 tmp.append(n%2) #print (tmp) for i in range(len(tmp)): if tmp[i]==1: s=print(i,end=' ') cs 2020. 12. 23.
[백준] 3058 1 2 3 4 5 6 7 8 9 import sys n=int(sys.stdin.readline()) for _ in range(n): tmp=list(map(int, sys.stdin.readline().split())) ans=0 oddtmp=[] for i in range(7): if tmp[i]%2==0: ans+=tmp[i]; oddtmp.append(tmp[i]) print("%d %d"%(ans,min(oddtmp))) cs 2020. 12. 23.
[백준] 3028 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import sys s=sys.stdin.readline() yabai=[1,0,0] for i in range(len(s)): if s[i]=='A': tmp=yabai[0] yabai[0]=yabai[1] yabai[1]=tmp elif s[i]=='B': tmp = yabai[1] yabai[1] = yabai[2] yabai[2] = tmp elif s[i]=='C': tmp = yabai[0] yabai[0] = yabai[2] yabai[2] = tmp print (yabai.index(1)+1) cs 요즘 세상엔 야바위도 코드를 짜네요 2020. 12. 23.
[백준] 3009 1 2 3 4 5 6 7 x=[] y=[] for _ in range(3): tmpx,tmpy=map(int,input().split()) x.append(tmpx) y.append(tmpy) print ("%d %d"%((2*( min(x)+max(x))-sum(x)) , 2*( min(y)+max(y))-sum(y))) cs 2020. 12. 22.
[백준] 2991 1 2 3 4 5 6 7 8 9 10 11 12 13 import sys a,b,c,d= (map(int, sys.stdin.readline().split())) p,m,n=(map(int, sys.stdin.readline().split())) cntp=0;cntm=0;cntn=0 if (p%(a+b)) 2020. 12. 22.
[백준] 2985 1 2 3 4 5 6 7 8 9 10 import sys a,b,c= (map(int, sys.stdin.readline().split())) if a+b==c: print("%d+%d=%d"%(a,b,c)); exit() elif a-b==c: print("%d-%d=%d"%(a,b,c)); exit() elif a*b==c: print("%d*%d=%d"%(a,b,c)); exit() elif int (a/b)==c: print("%d/%d=%d"%(a,b,c)); exit() elif a==b+c: print("%d=%d+%d"%(a,b,c)); exit() elif a==b-c: print("%d=%d-%d"%(a,b,c)); exit() elif a==b*c: print("%d=%d*%d"%(a.. 2020. 12. 22.
[백준] 2959 1 2 3 4 import sys tmp=list (map(int, sys.stdin.readline().split())) tmp.sort() print(tmp[0]*tmp[2]) cs 힌트를 보면서 직접 그려보면 쉽게 풀 수 있는 문제입니다. 2020. 12. 22.
[백준] 2953 1 2 3 4 5 6 7 8 import sys tmp=[] for i in range(5): tmp.append(sum( map(int, sys.stdin.readline().split()))) checkMax=max(tmp) for _ in range(5): if checkMax==tmp[_]: print("%d %d"%(_+1,checkMax)); break; cs 2020. 12. 22.
[백준] 2935 1 2 3 4 5 6 7 import sys a=int(sys.stdin.readline()) o=sys.stdin.readline() b=int(sys.stdin.readline()) if o[0]=='*': print(a*b) else: print(a+b) cs 2020. 12. 22.