본문 바로가기

Python1423

[백준] 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.
[백준] 2921 1 2 3 4 5 6 import sys ans=[] n=int(sys.stdin.readline()) for i in range(n+1): ans.append( (i+1)*3*i/2 ) print( int (sum(ans))) cs 2020. 12. 22.
[백준] 2903 1 2 import sys print( (2**int(sys.stdin.readline())+1)**2 ) cs stdin.readline()안쓰고 input()쓰면 한줄로도 가능하겠네요 점화식 구하시면 쉽게 구할 수 있습니다^^7 2020. 12. 22.
[백준] 2863 1 2 3 4 5 6 7 8 9 10 11 12 import sys a,b=map(int,sys.stdin.readline().split()) c,d=map(int,sys.stdin.readline().split()) tmp=[] tmp.append(a/c+b/d) tmp.append(c/d+a/b) tmp.append(d/b+c/a) tmp.append(b/a+d/c) for i in range(4): if tmp[i]==max(tmp): print(i); break Colored by Color Scripter cs 2020. 12. 22.