본문 바로가기

python-algorithm1422

백준 21734 SMUPC의 등장 1 2 3 4 5 6 7 8 9 10 def alphaToAscii(s): num= ord(s) ans=0 while num>0: ans+=num%10 num=num//10 return ans mystr=input() for i in mystr: print(i*(alphaToAscii(i))) cs 2021. 11. 30.
백준 21567 숫자의 개수 2 1 2 3 4 5 6 7 8 9 10 a=int(input()) b=int(input()) c=int(input()) num=a*b*c cnt=[0]*10 while num>0: cnt[num%10]+=1 num=num//10 for i in cnt: print(i) cs 2021. 11. 30.
백준 16483 접시 안의 원 1 2 t=int(input()) print(int (round( pow(t,2)/4 ,0)) ) cs 2021. 11. 30.
백준 21866 추첨을 통해 커피를 받자 1 2 3 4 5 6 7 8 9 10 11 12 score=list(map(int,input().split())) if score[0]>100: print('hacker'); exit() if score[1]>100: print('hacker'); exit() if score[2]>200: print('hacker'); exit() if score[3]>200: print('hacker'); exit() if score[4]>300: print('hacker'); exit() if score[5]>300: print('hacker'); exit() if score[6]>400: print('hacker'); exit() if score[7]>400: print('hacker'); exit() if sco.. 2021. 11. 30.
백준 22864 피로도 1 2 3 4 5 6 7 8 9 10 11 12 a,b,c,m=map(int, input().split()) fatigue=0 work=0 for i in range(24): if fatigue m: fatigue-=c continue else: fatigue+=a work+=b print(work) cs 2021. 11. 30.
백준 22938 백발백준하는 명사수 1 2 3 4 5 6 import math x1,y1,r1=map(int,input().split()) x2,y2,r2=map(int,input().split()) distance=math.sqrt(pow( abs(x1-x2),2)+pow( abs(y1-y2),2)) if distance 2021. 11. 30.
백준 23037 5의 수난 1 2 3 4 5 n=str(input()) ans=0 for i in n: ans+=pow(int(i),5) print(ans) cs 2021. 11. 29.
백준 9063 대지 1 2 3 4 5 6 7 8 9 10 11 n=int(input()) a, b = map(int, input().split()) if n 2021. 11. 28.
백준 14491 9진수 1 2 3 4 5 6 7 def nine(n): ans='' while n>0: ans+=str(n%9) n=n//9 return ans[::-1] print(nine(int(input()))) cs 2021. 11. 28.
백준 6679 싱기한 네자리 숫자 1 2 3 4 5 6 7 8 9 10 11 12 def decToK(n,k): ans=0 while n>0: ans+=n%k n=n//k return ans for i in range(1000,10000): ten=decToK(i,10) twe = decToK(i, 12) six = decToK(i, 16) if ten==twe and twe==six : print(i) cs 2021. 11. 19.
백준 2858 기숙사 바닥 1 2 3 4 5 6 a,b=map(int, input().split()) for i in range(1,10001): for j in range(1,10001): if i*j==a+b and a==2*i+2*j-4 : print(max(i,j),min(i,j)) exit() cs 사실 이 문제는 수학문제인데요 입력받는 값을 a,b라고하면 a+b=x*y a=2x+2y-4 두 식을 만족하는 x,y의 해를 구하고 큰 값을 앞에 작은 값을 뒤에 출력하면됩니다. 2021. 11. 19.
백준 14782 Bedtime Reading, I 1 2 3 4 5 6 def divisiors(num): ans=0 for i in range(1,num+1): if num%i==0: ans+=i print(ans) divisiors(int(input())) cs 2021. 11. 19.