python-algorithm1422 [백준] 10930 1 2 import hashlib print ( hashlib.sha256( input().encode() ).hexdigest() ) cs 2021. 1. 12. [백준] 10929 1 2 import hashlib print ( hashlib.sha224( input().encode() ).hexdigest() ) cs 2021. 1. 12. [백준] 10928 1 2 import hashlib print ( hashlib.sha1( input().encode() ).hexdigest() ) cs 2021. 1. 12. [백준] 10927 1 2 import hashlib print ( hashlib.md5( input().encode() ).hexdigest() ) cs hashlib 라이브러리를 이용하시면 쉽게 구하실 수 있습니다 2021. 1. 12. [백준] 10874 1 2 3 4 5 6 7 import sys for _ in range(int(sys.stdin.readline())): tmp=list(map(int,sys.stdin.readline().split())) cnt=0 for i in range(10): if tmp[i]== (i+1)%5 : cnt+=1 if cnt==8 : print(_+1) cs 문제 에서 말하는 '첫번째' 가 python에서는 0부터 시작이죠 그래서 line 6에 i+1을 해줬고 mod 는 나머지를 뜻하므로 % 연산자를 쓰시면 됩니다. 그외에는 딱히 특이사항이 없네요 2021. 1. 12. [백준] 10870 1 2 3 4 5 6 7 8 9 def pibo(a): if a==0 : return 0 if a==1: return 1 return pibo(a-2)+pibo(a-1) print (pibo(int(input()))) cs 피보나치 수를 구현하는것 그 자체는 어렵지 않습니다만.. input 수가 커지게 되면 시간복잡도가 지수적으로 늘어나서 메모이제이션(memoization) 방식을 쓰셔야 될 것 같네요 2021. 1. 12. [백준] 10865 1 2 3 4 5 6 7 8 9 import sys n,m=map(int,sys.stdin.readline().split()) cnt=[0]*(n+1) for i in range(m): a,b=map(int,sys.stdin.readline().split()) cnt[a]+=1 cnt[b]+=1 for i in range(1,n+1): print(cnt[i]) cs 그래프 처럼 보이는데 친구의 수만 구하면 되서 list 하나로 쉽게 구현 가능합니다. 2021. 1. 12. [백준] 10864 1 2 3 4 5 6 7 8 9 10 import sys n,m=map(int,sys.stdin.readline().split()) cnt=[] for i in range(m): a,b=map(int,sys.stdin.readline().split()) cnt.append(a) cnt.append(b) for i in range(1,n+1): print(cnt.count(i)) cs 2021. 1. 11. [백준] 10823 1 2 3 4 5 6 7 import sys s="" while True: try: s+=input() except : break print(sum(map(int, s.split(",")))) cs 다른 문제랑 다르게 입력이 좀 특이 합니다. 하나의 string으로 다 합치고 나중에 합을 구하는 방식으로 풀었습니다. 2021. 1. 11. [백준] 10822 1 2 3 import sys s=list (map(int, sys.stdin.readline().split(","))) print(sum(s)) Colored by Color Scripter cs 2021. 1. 11. [백준] 10821 1 2 3 import sys s=sys.stdin.readline().split(",") print(len(s)) cs 2021. 1. 11. [백준] 10820 1 2 3 4 5 6 7 8 9 10 11 12 13 import sys while True: s=sys.stdin.readline() a=0;b=0;c=0;d=0 for i in range(len(s)-1): if ord(s[i])==32: d+=1 elif ord(s[i])>= 48 and ord(s[i])= 65 and ord(s[i])= 97 and ord(s[i]) 2021. 1. 11. 이전 1 ··· 92 93 94 95 96 97 98 ··· 119 다음