백준
-
[🐉 백준 7단계] 문자열Algorithm/케로베로스 2020. 12. 12. 11:34
백준 7단계 문자열 11654. print(ord(input())) 11720. n = int(input()) a = str(input()) s = 0 for i in a: i = int(i) s += i print(s) 10809. import string alpha = list(string.ascii_lowercase) answer = [] word = input() for a in alpha: if a in word: answer.append(str(word.index(a))) else: answer.append('-1') print(' '.join(answer)) 2675. t = int(input()) for _ in range(t): a, b = input().split() answer = '..
-
[🐉 백준 6단계] 함수Algorithm/케로베로스 2020. 12. 6. 18:22
백준 6단계 함수 Q. 15596 def solve(a): return sum(a) Q. 4673 # 생성자 구하는 함수 def solve(a): a = str(a) s = 0 for i in a: s += int(i) s += int(a) return s # 구한 생성자를 d에 넣는다 d = set() for i in range(1, 10001): a = solve(i) d.add(a) # d에 없는 것만 출력하면 셀프넘버 for i in range(1, 10001): if i in d: continue else: print(i) Q. 1065 # 한수 구하는 함수 def han(a): a = str(a) if len(a) == 1: return 1 elif len(a) == 2: return 1 el..
-
[🐉 백준 5단계] 1차원 배열Algorithm/케로베로스 2020. 12. 5. 16:26
백준 5단계 1차원 배열 Q. 10818 n = int(input()) a = list(map(int, input().split())) print(min(a), max(a)) Q. 2562 l = [] for _ in range(9): l.append(int(input())) m = max(l) idx = l.index(m) print(m) print(idx+1) Q. 2577 l = [0] * 10 s = 1 for _ in range(3): s = s * int(input()) s = str(s) for i in s: i = int(i) l[i] = l[i] + 1 for i in l: print(i) Q. 3052 l = [] answer = [] for _ in range(10): l.append..
-
[🐉 백준 4단계] While문Algorithm/케로베로스 2020. 12. 5. 13:03
Q.10952 while True: a, b = map(int, input().split()) if a == 0 and b == 0: break print(a+b) Q.10951 # EOFerror (입력이 없을때) while True: try: a, b = map(int, input().split()) print(a+b) except: break Q.1110 n = input() # 입력받는 값 a = n # 계산에 사용해 줄 값 count = 0 # 출력 while True: # 10보다 작으면 if len(a) == 1: s_n = a new_n = a[-1] + s_n[-1] count += 1 # 10보다 크면 else: s_n = str(int(a[0]) + int(a[1])) new_n = ..
-
[🐉 백준 3단계] for문Algorithm/케로베로스 2020. 11. 21. 19:36
Q1. 2739번 구구단 n = int(input()) for i in range(1, 10): print(str(n) + ' * ' + str(i) + ' = ' + str(n*i)) Q2. 10950번 A+B - 3 n = int(input()) for i in range(n): a, b = map(int, input().split()) print(a+b) Q3. 8983번 합 n = int(input()) s = 0 for i in range(n+1): s += i print(s) Q4. 15552번 빠른 A+B import sys t = int(input()) for i in range(t): a, b = map(int, sys.stdin.readline().split()) print(a+b) Q..
-
[🐉 백준 1단계] 입출력과 사칙연산Algorithm/케로베로스 2020. 11. 21. 18:20
Q1 문제 2557. Hello World print("Hello World!") Q2 문제 10718. We love krill print("강한친구 대한육군 \n" * 2) Q3 문제 10171. 고양이 print("\ /\ \n ) ( ')\n( / )\n \(__)|") Q4 문제 10172번. 개 print('|\_/|\n|q p| /}\n( 0 )"""\ \n|"^"` |\n||_/=\\\__|') Q5 문제 1000.번 A+B A, B = map(int, input().split()) print(A+B) Q6 문제 1001번. A-B A, B = map(int, input().split()) print(A-B) Q7 문제 10998번. A*B A, B = map(int, input().spl..
-
[🤷♀️ 백준] 1912번. 연속합Algorithm/1일 1코테 2020. 11. 16. 17:19
문제 www.acmicpc.net/problem/1912 1912번: 연속합 첫째 줄에 정수 n(1 ≤ n ≤ 100,000)이 주어지고 둘째 줄에는 n개의 정수로 이루어진 수열이 주어진다. 수는 -1,000보다 크거나 같고, 1,000보다 작거나 같은 정수이다. www.acmicpc.net 시도 # 시간초과 t = int(input()) l = list(map(int, input().split())) left, right = 0, t-1 m = float('-inf') while left l[right]: right = right - 1 else: left = left + 1 s = sum(l[left:right+1]..