본문 바로가기

분류 전체보기1534

[백준] 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.
[백준] 15781 1 2 3 4 5 import sys dumm , dummy=map(int, sys.stdin.readline().split()) tmp1=list(map(int, sys.stdin.readline().split())) tmp2=list(map(int, sys.stdin.readline().split())) print(max(tmp1)+max(tmp2)) cs 2021. 1. 4.
[백준] 15780 1 2 3 4 5 6 7 8 9 import sys import math n,k=map(int,sys.stdin.readline().split()) cnt=0 tmp=list(map(int,sys.stdin.readline().split())) for i in range(k): cnt+= math.ceil( (tmp[i]/2)) if n>cnt: print("NO") else: print("YES") cs 연속으로 꼽으면 안된다는 것을 정의내리는것이 즉, 2로 나누고 버림을 하면 됩니다. 2021. 1. 4.
[백준] 15667 1234import sysk=int(sys.stdin.readline())for i in range(102): if (k-1) ==i*(i+1) : print(i); breakcs 2021. 1. 4.
[백준] 14920 1 2 3 4 5 6 7 8 9 import sys c=[] c.append(int(sys.stdin.readline())) for i in range(1000000): if c[i]==1: break if c[i]%2==0 :c.append( c[i]//2 ) else: c.append( 3*c[i]+1 ) print(len(c)) cs 2021. 1. 4.
[백준] 14909 1 2 3 4 5 6 import sys tmp=list(map(int, sys.stdin.readline().split())) cnt=0 for i in range(len(tmp)): if tmp[i]>0: cnt+=1 print(cnt) Colored by Color Scripter cs 2021. 1. 4.
[백준] 14720 1 2 3 4 5 6 7 import sys cnt=0 n=int(sys.stdin.readline()) tmp=list(map(int,sys.stdin.readline().split())) for i in range(n): if tmp[i]==(cnt%3): cnt+=1 print(cnt) Colored by Color Scripter cs 이게 문제가 잘 이해가 안될수도 있는데 1. 맨처음 무조건 딸기우유를 한팩 마셔야 하므로 딸기->초코->바나나-> 다시 딸기 이 루틴을 반드시 지켜야합니다. 2021. 1. 4.
[백준] 14656 1 2 3 4 5 6 7 pyimport sys n=int(sys.stdin.readline()) tmp=list(map(int,sys.stdin.readline().split())) cnt=0 for i in range(n): if tmp[i]!=i+1 : cnt+=1 print(cnt) Colored by Color Scripter cs 2021. 1. 4.
[백준] 14579 1 2 3 4 5 6 import sys a,b= map(int,sys.stdin.readline().split()) start= int ((1+a)*a/2) for i in range(a+1,b+1): start*= int ( (i*(1+i))/2) print(start%14579) cs 2020. 12. 29.