python-algorithm1422 [백준] 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. [백준] 15917 1 2 3 4 5 6 7 8 9 10 import sys import math def log2(x): return (math.log10(x) / math.log10(2) ) def isPower2(n): if (math.ceil(log2(n))== math.floor(log2(n))) : return 1 else: return 0 for _ in range(int(sys.stdin.readline())): a=int(sys.stdin.readline()) print( isPower2(a) ) Colored by Color Scripter cs 본 문에서 주어진 힌트와 유사한 방법 이겠네요 엄청나게 큰 수나 엄청나게 작은 수를 다루기 위해 지수와 로그 개념이 도입됩니다. 그리고 로그의 성질을 이용해서 ex.. 2021. 1. 4. [백준] 15820 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import sys s1,s2=map(int,sys.stdin.readline().split()) score1=0 score2=0 for i in range(s1): a,b=sys.stdin.readline().split() if a==b : score1+=1 for i in range(s2): a, b = sys.stdin.readline().split() if a == b: score2 += 1 if score1==s1 and score2==s2:print("Accepted") elif score1!=s1 :print("Wrong Answer") elif score1==s1 and (score2!=s2) : print("Why Wrong!!!.. 2021. 1. 4. [백준] 15818 1 2 3 4 5 6 7 8 9 import sys a,b=map(int,sys.stdin.readline().split()) tmp=list(map(int,sys.stdin.readline().split())) for i in range(a): tmp[i]%=b cnt=tmp[0] for i in range(1,a): cnt*=tmp[i] print(cnt%b) Colored by Color Scripter cs 2021. 1. 4. [백준] 15784 1 2 3 4 5 6 7 8 9 10 11 12 import sys n,a,b=map(int, sys.stdin.readline().split()) tmp=[ list (map(int,sys.stdin.readline().split())) for _ in range (n) ] cnt=0 jinseo=tmp[a-1][b-1] for _ in range(n): if jinseo 2021. 1. 4. 이전 1 ··· 101 102 103 104 105 106 107 ··· 119 다음