백준 단계별 코딩 테스트

백준 15596번: 정수 N개의 합 함수 만들기 Python 2, Python 3, PyPy, PyPy3: def solve(a: list) -> int a: 합을 구해야 하는 정수 n개가 저장되어 있는 리스트 (0 ≤ a[i] ≤ 1,000,000, 1 ≤ n ≤ 3,000,000) 리턴값: a에 포함되어 있는 정수 n개의 합 (정수) [ref] https://www.acmicpc.net/problem/15596 15596번: 정수 N개의 합 C++17, Java 8, Python 3, C11, PyPy3, C99, C++98, C++11, C++14, Python 2, PyPy2, Go, C99 (Clang), C++98 (Clang), C++11 (Clang), C++14 (Clang), C11 (..
백준 8958번 import sys n = int(sys.stdin.readline().rstrip()) for i in range(n): s = 0 m = 0 p = 'X' str = sys.stdin.readline().rstrip() for c in str: if c == 'O': if p != 'O': p = 'O' m += 1 else: m += 1 s += m else: m = 0 p = 'X' print(s) * 조금 생각해야하는 문제였다 백준 4344번 import sys num = int(sys.stdin.readline().rstrip()) for n in range(num): i = 0 L = list(map(int, sys.stdin.readline().rstrip().split()..
백준 10818번 import sys num = int(sys.stdin.readline().rstrip()) array = list(map(int, sys.stdin.readline().rstrip().split(' '))) print(min(array), end=' ') print(max(array)) * rstrip()을 먼저 하고 split() 을 해야 에러가 나지 않는다! * python min, max() 함수를 사용 import sys num = int(sys.stdin.readline().rstrip()) array = list(map(int, sys.stdin.readline().rstrip().split(' '))) mini = 1000000 maxi = -1000000 for i in..
백준 10952번 import sys while True: num = list(map(int, sys.stdin.readline().rstrip().split(' '))) if num[0] == 0: break print(num[0] + num[1]) * 정답 while True: 는 무한 루프이다. 백준 10951번 다음 문제는 while 멈추는 조건이 없는(최대 몇개의 문제가 들어오는지 모르는) 문제이다. 이럴 때에는 무한하게 루프가 돌면 안되기 때문에 try except 를 사용한다. EOF : End of file 문제 = 데이터를 읽으려고 시도했지만 어떠한 이유 때문에 데이터 읽는 것이 실패했을 때 (예를 들면 더이상 입력 데이터가 없을 때) 생기는 에러 import sys while True:..
섬섬옥수수
'백준 단계별 코딩 테스트' 카테고리의 글 목록 (5 Page)