본문 바로가기

python-algorithm1422

[백준] 9295 1 2 3 4 import sys for i in range(1,int(sys.stdin.readline())+1): tmp=list(map(int,sys.stdin.readline().split())) print ("Case %d: %d"%(i,sum(tmp))) cs 2020. 12. 24.
[백준] 9094 1 2 3 4 5 6 7 8 9 10 import sys def sh(n,m): cnt=0 for a in range(1,n): for b in range(a+1,n): if (a**2+b**2+m)%(a*b)==0: cnt+=1 return cnt for _ in range(int(sys.stdin.readline())): n,m=map(int,sys.stdin.readline().split()) print(sh(n,m )) cs 엄청난 브루트 포스 방식입니다. python3 시간초과나서 pypy3로 채점했습니다.. sorry.. 2020. 12. 24.
[백준] 9085 1 2 3 4 5 import sys for _ in range(int(sys.stdin.readline())): dummy=sys.stdin.readline() tmp=list(map(int, sys.stdin.readline().split())) print(sum (tmp)) Colored by Color Scripter cs 2020. 12. 24.
[백준] 8932 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 import sys def track_100(p): return int(9.23076*pow((26.7-p),1.835 ) ) def track_200(p): return int(4.99087*pow((42.5-p),1.81 ) ) def track_800(p): return int(0.11193*pow((254-p),1.88 ) ) def field_n(p): return int(1.84523 * pow((p-75), 1.348)) def field_p(p): return int(56.0211 * pow((p-1.5), 1.05)) def field_m(p): return int(0.188807 * pow((p-210.. 2020. 12. 24.
[백준] 7770 1 2 3 4 5 6 7 8 import sys n=int(sys.stdin.readline()) h=0 block=0 while block 2020. 12. 24.
[백준] 7510 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import sys def isRAT(a): if a[2]**2==a[1]**2+a[0]**2 : return 1 else: return 0 for i in range(1,int(sys.stdin.readline())+1): a=sorted(map(int, sys.stdin.readline().split())) print("Scenario #%d:"%i) if isRAT(a)==1: print("yes",'\n') else: print("no",'\n') Colored by Color Scripter cs 2020. 12. 24.
[백준] 6378 1 2 3 4 5 6 7 8 9 10 import sys sys.setrecursionlimit(10**6) def digitalroot(n): return sum(map(int,n)) if len(n) ==1 else digitalroot(str(sum(map(int,n)))) while True: n=input() if n=='0': exit() else : print (digitalroot(n)) Colored by Color Scripter cs 2020. 12. 24.
[백준] 6322 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import sys import math cnt=1 while True: a,b,c=map(int,sys.stdin.readline().split()) if a==b and b==c and a==0: break elif (a>=c or b>=c) and c!=-1 : print("Triangle #%d"%cnt); print("Impossible.") elif a==-1: print("Triangle #%d"%cnt); print("a = %.3f"% (math.sqrt(pow(c,2)-pow(b,2)))) elif b == -1: print("Triangle #%d" % cnt); print("b = %.3f" % (math.sqrt(pow(c.. 2020. 12. 24.
[백준] 6131 1 2 3 4 5 6 7 import sys n=int(sys.stdin.readline()) cnt=0 for i in range(1,501): for j in range(1,501): if pow(j,2)+n==pow(i,2): cnt+=1 print(cnt) cs 2020. 12. 24.
[백준] 5717 1 2 3 4 5 import sys while True: a,b=map(int, sys.stdin.readline().split()) if a==0 and b==0: break else: print(a+b) cs 2020. 12. 24.
[백준] 5612 1 2 3 4 5 6 7 8 9 10 11 12 import sys n=int(sys.stdin.readline()) tmp=[] tmp.append(int(sys.stdin.readline())) for i in range(n): a,b=map(int,sys.stdin.readline().split()) tmp.append( tmp[i]+a-b) for i in range(n+1): if tmp[i] 2020. 12. 23.
[백준] 5523 1 2 3 4 5 6 7 8 import sys cnta=0 cntb=0 for _ in range(int(sys.stdin.readline())): a,b=map(int,sys.stdin.readline().split()) if a>b: cnta+=1 elif a 2020. 12. 23.