본문 바로가기

분류 전체보기1534

[백준] 17450 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import sys s_price,s_weight=map(int,sys.stdin.readline().split()) n_price,n_weight=map(int,sys.stdin.readline().split()) u_price,u_weight=map(int,sys.stdin.readline().split()) if s_price*10>=5000: s_gsb= (s_weight*10)/(s_price*10 - 500) else : s_gsb=(s_weight*10)/(s_price*10 ) if n_price*10>=5000: n_gsb= (n_weight*10)/(n_price*10 - 500) else : n_gsb=(n_weight*10).. 2021. 1. 5.
[백준] 17356 1 2 3 4 5 import sys a,b=map(int,sys.stdin.readline().split()) m=(b-a)/400 print(1/(1+pow(10,m))) cs 힌트에 처럼 python 에서는 pow 함수를 이용하시면 됩니당 2021. 1. 5.
[백준] 17284 1 2 3 4 5 6 7 8 import sys cnt=5000 tmp=list(map(int, sys.stdin.readline().split())) for i in range(len(tmp)): if tmp[i]==1: cnt-=500 elif tmp[i] == 2: cnt -= 800 elif tmp[i] == 3: cnt -= 1000 print(cnt) Colored by Color Scripter cs 문제명 Vending machine , 한국어로는 자판기죠 자판기 기능 생각해보시면서 구현하시면 쉽습니다. 예외조건으로 주어진 돈을 초과해서 버튼을 누르거나 잔돈의 종류별 갯수를 출력해야하는데 특정 잔돈이 부족하다거나 하는 조건이 있으면 더 재밌겠네요 2021. 1. 5.
[백준] 17174 1 2 3 4 5 6 7 8 import sys a,b = map(int, sys.stdin.readline().split()) cnt=a while True: cnt+=a//b a= a//b if a==0: break print(cnt) Colored by Color Scripter cs 제가 설정한 변수 a가 문제에서는 N에 해당하니 1달러, 10달러, 100달러 .. 과 같이 지폐를 세는방식 line3 에서 초기값을 설정해줍니다 2021. 1. 5.
[백준] 16673 1 2 3 4 5 6 import sys c,k,p=map( int , (sys.stdin.readline().split())) cnt=0 for i in range(c+1): cnt+=i*(i*p+k) print(cnt) Colored by Color Scripter cs 크게 어렵지 않습니다. 와인 배경은 크게 중요하지 않고 수식만 그대로 구현해주시면 됩니다. 2021. 1. 5.
[백준] 16561 1 2 3 4 5 6 7 8 import sys n=int(sys.stdin.readline()) cnt=0 for i in range(1,n//3): for j in range(1, n // 3): for k in range(1, n // 3): if 3*i+3*j+3*k==n: cnt+=1 print(cnt) cs 3중 for문 .. 허허 interpreter를 python3로 하시면 시간초과뜹니다. pypy3로 하면 통과는 되는데 이렇게 하시면 안돼용 2021. 1. 5.
[백준] 16504 1 2 3 4 5 6 7 import sys n=int(sys.stdin.readline()) cnt=0 for i in range(n): tmp=list( map( int , (sys.stdin.readline().split()))) cnt+=sum(tmp) print(cnt) Colored by Color Scripter cs 이건 손으로 적어가면서 해보면 이해가 더 빠른데요 그냥 다 더하면 됩니다 ㅎㅎ 2021. 1. 5.
[백준] 16485 1 2 3 4 import sys a,b=map(int,sys.stdin.readline().split()) if a%b==0 :print( int (a/b)) else: print("%.10f"% (a/b)) cs 중학교시절때 배웠던 삼각형의 내심 , 외심 등이 생각이 나네요 2021. 1. 5.
[백준] 16479 1 2 3 4 5 6 import sys k=int(sys.stdin.readline()) d1,d2= map(int,sys.stdin.readline().split()) ans =k ** 2 - (((d1 - d2) / 2) ** 2) if ans%1==0: print(int (ans)) else : print(ans ) cs 2021. 1. 4.
[백준] 15995 1 2 3 4 import sys a,m= map(int,sys.stdin.readline().split()) for i in range(1,10000): if (a*i)%m ==1 : print(i) ; break cs 2021. 1. 4.
[백준] 15953 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import sys for _ in range(int(sys.stdin.readline())): cnt=0 a,b=map(int, sys.stdin.readline().split()) if a==1: cnt+=5000000 elif a>=2 and a= 4 and a = 7 and a = 11 and a = 16 and a =2 and b= 4 and b = 8 and b = 16 and b 2021. 1. 4.
[백준] 15923 1 2 3 4 5 6 7 8 9 10 import sys n=int(sys.stdin.readline()) tmp=[] for i in range(n): a,b=map(int,sys.stdin.readline().split()) tmp.append( (a,b) ) cnt=0 for i in range(1,n): cnt+= abs (tmp[i][0]-tmp[i-1][0]) + abs (tmp[i][1]-tmp[i-1][1]) print(cnt + abs (tmp[0][0]-tmp[len(tmp)-1][0]) + abs (tmp[0][1]-tmp[len(tmp)-1][1])) cs 2021. 1. 4.