python-algorithm1422 [백준] 1837 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 import sys import math def checkPrime(n): sieve=[True]*n a=int(math.sqrt(n)) for i in range(2,a+1): if sieve[i]: for j in range(i+i,n,i): sieve[j]=False return [i for i in range(2,n) if sieve[i]==True] p,k=map(int, sys.stdin.readline().split()) ans=0 tmp=checkPrime(k) for i in range (len(tmp)): if p%tmp[i]==0: print("BAD %d"%tmp[i]) exit() if ans==.. 2020. 12. 17. [백준] 1703 1 2 3 4 5 6 7 8 9 10 11 import sys while 1: tmp=list(map(int, sys.stdin.readline().split())) if tmp[0]==0: exit() else: ans=1 if tmp[0]==1: print(tmp[1]-tmp[2]) else: for i in range(1,tmp[0]+1): ans=tmp[i*2-1]*ans-tmp[i*2] print(ans) cs 2020. 12. 17. [백준] 1598 1 2 3 4 5 import sys a,b=map(int,sys.stdin.readline().split()) a-=1 b-=1 print( abs (a//4-b//4)+abs(b%4-a%4)) cs python은 근본있는 언어라 0부터 시작하기에 a,b를 각각 1을 빼줍니다. 4를 기준으로 하는 수열이라 보시면 쉽게 풀 수 있습니다. 2020. 12. 17. [백준] 1267 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import sys n=int(sys.stdin.readline()) tmp=list (map(int, sys.stdin.readline().split())) youn=0 mins=0 for i in range(n): if tmp[i] 2020. 12. 17. [백준] 1247 1 2 3 4 5 6 7 8 9 10 import sys tmp=[] for i in range(3): for j in range(int(sys.stdin.readline())): tmp.append( int(sys.stdin.readline())) if sum(tmp)>0: print("+") if sum(tmp) == 0: print("0") if sum(tmp) 2020. 12. 17. [백준] 1085 1 2 3 4 5 a,b,c,d=map(int, input().split()) if a==c or b== d: print(0) else: print (min(abs(a-c),abs(d-b),a,b)) cs 2020. 12. 17. [백준] 19944 1 2 3 4 5 n,m=map(int,input().split()) if m==1 or m==2: print("NEWBIE!") elif n 2020. 12. 17. [백준] 19698 1 2 3 4 5 n,w,h,l=map(int,input().split()) if n 2020. 12. 17. [백준] 17388 1 2 3 4 5 6 7 8 9 tmp=list(map(int,input().split())) if not sum(tmp) 2020. 12. 17. [백준] 17362 1 2 3 4 5 6 7 8 9 n=int(input()) if n 2020. 12. 17. [백준] 16486 1 2 3 d1=int(input()) d2=int(input()) print(2*d1+2*3.141592*d2) cs 2020. 12. 17. [백준] 16431 1 2 3 4 5 6 7 8 9 10 a1,a2=map(int,input().split()) b1,b2=map(int,input().split()) c1,c2=map(int,input().split()) if abs(b1-c1)+abs(b2-c2)> max(abs(a1-c1),abs(a2-c2)): print("bessie") if abs(b1-c1)+abs(b2-c2) 2020. 12. 17. 이전 1 ··· 111 112 113 114 115 116 117 ··· 119 다음