python-algorithm1422 [백준] 10829 1 2 3 4 5 6 s=int(input()) ans='' while s!=0: ans+=str(s%2) s//=2 print(ans[::-1]) cs 2021. 1. 28. [백준] 11816 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 s=str(input()) ans=0 if s[0]!='0': print(int(s)) else: if s[1]=='x': s=s[2:] alpha='abcdef' for i in range(len(s)): if s[i] in alpha: ans+=(ord (s[i])-87)*pow(16,len(s)-i-1) else: ans+=int(s[i])*pow(16,len(s)-i-1) else: s=s[1:] for i in range(len(s)): ans+= int(s[i])*pow(8,len(s)-i-1) print(ans) Colored by Color Scripter cs 2021. 1. 26. [백준] 11179 1 2 3 4 5 6 7 8 9 s=int(input()) mybin='' while s!=0: mybin+= str(s%2) s//=2 ans=0 for i in range(len(mybin)): ans+= int (mybin[i])*pow(2,len(mybin)-1-i) print(ans) Colored by Color Scripter cs 2021. 1. 26. [백준] 11098 1 2 3 4 5 6 7 for _ in range(int(input())): price,name=0,'Daniel' for i in range(int(input())): a,b=input().split() a=int(a) if price 2021. 1. 26. [백준] 11091 1 2 3 4 5 6 7 8 9 10 11 for _ in range(int(input())): s=input().lower() tmp=[1]*26 for i in s: if ord(i)>96 and ord(i) 2021. 1. 26. [백준] 11070 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import sys for _ in range(int(sys.stdin.readline())): n,m=map(int, sys.stdin.readline().split()) getscores,losescores=[0]*n,[0]*n for i in range(m): a,b,p,q=map(int, sys.stdin.readline().split()) getscores[a-1]+=p ; losescores[a-1]+=q getscores[b-1]+=q; losescores[b-1]+=p ans=[] for i in range(n): if getscores[i]**2+losescores[i]**2!=0: ans.append(getscores[i].. 2021. 1. 26. [백준] 9946 1 2 3 4 5 6 7 8 9 10 11 cnt=1 while 1: a=input() b=input() if a=='END' and b=='END' :break tmpa,tmpb=[0]*26, [0]*26 for i in a: tmpa[ord(i)-97]+=1 for i in b: tmpb[ord(i) - 97] += 1 if tmpa==tmpb: print("Case %d: same"%cnt) else: print("Case %d: different"%cnt) cnt+=1 Colored by Color Scripter cs 2021. 1. 25. [백준] 9933 1 2 3 4 5 tmp=[] for _ in range(int(input())): tmp.append(input()) for i in tmp: if i[::-1] in tmp: print(len(i),i[len(i)//2]) ; break cs 2021. 1. 25. [백준] 9093 1 2 3 4 5 for _ in range(int(input())): s=list(map(str, input().split())) new=[] for i in s:new.append(i[::-1]) print(*new) cs 2021. 1. 25. [백준] 8974 1 2 3 4 5 6 7 8 9 def make(n): tmp=[] for i in range(1,n+1): for j in range(i): tmp.append(i) return tmp a,b=map(int,input().split()) print( sum (make(b)[:b])- sum(make(b)[:a-1]) ) cs 2021. 1. 25. [백준] 8595 1 2 3 4 5 6 7 8 n=int(input()) s=input() numbers='1234567890' tmps='' for i in s: if i in numbers : tmps+=i else: tmps+=' ' print (sum( list(map(int, tmps.split())))) cs 처음 입력받은 문자열에서 숫자에 해당하는 부분만 걸러내서 새로운 문자열 합쳐서 만들고 그 문자열을 다시 split()으로 나눠서 정수로 type casting 해서 구했습니다. 2021. 1. 25. [백준] 6996 1 2 3 4 5 6 7 for _ in range(int(input())): a,b=input().split() tmpa,tmpb=[0]*26,[0]*26 for i in a: tmpa[ord(i)-97]+=1 for i in b: tmpb[ord(i) - 97] += 1 if tmpa==tmpb: print("%s & %s are anagrams."%(a,b)) else: print("%s & %s are NOT anagrams."%(a,b)) cs 저는 문자열을 입력받아서 알파벳 개수를 이용해서 문제를 해결했습니다. 2021. 1. 25. 이전 1 ··· 82 83 84 85 86 87 88 ··· 119 다음