본문 바로가기

problem solving42

1204. [S/W 문제해결 기본] 1일차 - 최빈수 구하기 t = int(input()) for q in range(t): n = int(input()) lst = list(map(int,input().split())) lst_num = [0]*101 for i in range(1000): lst_num[lst[i]] += 1 maxx = max(lst_num) count = lst_num.count(maxx) while count !=1: count -= 1 a = lst_num.index(maxx) lst_num[a] = 0 ans = lst_num.index(maxx) print('#%d' % n,ans) 2019. 9. 15.
1288. 새로운 불면증 치료법 t = int(input()) for q in range(t): n = input() ncopy = n nlst = list(n) #n을 리스트에 저장 num = [''] * 10 # 0~9 까지 한번이라도 나오면 1로 표시 k = 1 # 실행횟수 ans = '' while num.count('1') != 10: k = k + 1 ans = int(ncopy) for i in range(len(ncopy)): num[int(nlst[i])] = '1' ncopy = str(int(n) * k) nlst = list(ncopy) print('#%d'%(q+1),ans) 2019. 9. 14.
1928. Base64 Decoder t = int(input()) Base64 = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/'] for p in range(t): strr = input() # 문자열 입력 ans = '' for q in range(0,len(strr),+4):#인코딩 문자 4개씩 집어넣기 four = strr[q].. 2019. 9. 14.
1940. 가랏! RC카! t = int(input()) for p in range(t): n = int(input()) #명령어 개수 speed = 0 m = 0 #이동거리 for i in range(n): #명령어, 가속도 입력받기 command_accel = list(map(int,input().split())) if command_accel[0] == 1: # 가속 speed = speed + command_accel[1] if command_accel[0] == 2: # 감속 if command_accel[1] > speed: speed = 0 #가속도가 속도보다 큰 경우 else: speed = speed - command_accel[1] # 속도가 가속도보다 크거나 같은 경우 m = m + speed print('#%.. 2019. 9. 14.
1945. 간단한 소인수분해 t = int(input()) for p in range(t): n = int(input()) lst = [0] * 5 # 2,3,5,7,11 while True: if n % 11 == 0: n = n / 11 lst [4] += 1 elif n % 7 == 0: n = n / 7 lst [3] += 1 elif n % 5 == 0: n = n / 5 lst [2] += 1 elif n % 3 == 0: n = n / 3 lst [1] += 1 elif n % 2 == 0: n = n / 2 lst [0] += 1 else: break; print('#%d'%(p+1),lst[0],lst[1],lst[2],lst[3],lst[4]) 2019. 9. 13.
1946. 간단한 압축 풀기 t = int(input()) for p in range(t): n = int(input()) char = 0 num = 0 sw = 0 strr = '' left_num = 0 print('#%d' % (p + 1)) for q in range(n): char,num = map(str,input().split()) num = int(num) if sw + num == 10: sw = sw + num strr = strr + (char * num) print(strr) sw = 0 strr = '' elif sw + num 10: left_num.. 2019. 9. 13.