본문 바로가기

백준1056

백준 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.
백준 9288 More Dice 1 2 3 4 5 6 7 n=int(input()) for i in range(n): number=int(input()) print("Case %d:"%(i+1)) for j in range(1,number//2+1): if j 2021. 11. 19.
백준 6975 Deficient, Perfect, and Abundant 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 import math n=int(input()) for i in range(n): if i !=0 : print() tmp=1 number=int(input()) cnt=math.ceil(math.sqrt(number)) if number==1: print ("1 is a deficient number.") else: for j in range(2,cnt): if number%j==0: tmp+=j+ number//j if tmpnumber: print("%d is an abundant number."%number) cs 약수의 합으로 분류하는 문제인데 LIne 7같이 한 이유는 1부터 입력받은 숫자까지 전부 반복할 필요 없.. 2021. 11. 12.
2167 2차원 배열의 합 1 2 3 4 5 6 7 8 9 10 11 12 n,m=map(int, (input().split())) list_1 = [] for i in range(n): list_1.append(list(map(int, input().split()))) k=int(input()) for i in range(k): a,b,c,d=map(int,input().split()) ans=0 for j in range(a-1,c): for k in range(b-1,d): ans+=list_1[j][k] print(ans) Colored by Color Scripter cs 2021. 11. 12.
백준 2738 행렬 덧셈 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 n,m=map(int, (input().split())) list_1 = [] list_2 = [] for i in range(n): list_1.append(list(map(int, input().split()))) for i in range(n): list_2.append(list(map(int, input().split()))) ans=[] for i in range(n): tmp = [] for j in range(m): tmp.append(list_1[i][j]+list_2[i][j]) ans.append(tmp) for i in ans: print(*i) Colored by Color Scripter cs 2021. 11. 12.
백준 2745 진법 변환 1 2 3 4 5 6 7 8 #print(ord('A')-55) s=input().split() n,b=s[0],int(s[1]) ans=0 for i in range(len(n)): if n[len(n)-i-1].isupper(): ans+=(ord(n[len(n)-i-1])-55)*pow(b,i) else : ans+=int(n[len(n)-i-1])*pow(b,i) print(ans) Colored by Color Scripter cs 2021. 11. 2.