본문 바로가기

2022 하반기/Python15

백준 2231 python https://www.acmicpc.net/problem/2231 2231번: 분해합 어떤 자연수 N이 있을 때, 그 자연수 N의 분해합은 N과 N을 이루는 각 자리수의 합을 의미한다. 어떤 자연수 M의 분해합이 N인 경우, M을 N의 생성자라 한다. 예를 들어, 245의 분해합은 256(=245+2+4+5)이 www.acmicpc.net def generator(n): strN = str(n) for i in range(0,len(strN)): n += int(strN[i]) return n N = input() iN = int(N) if iN 196 minSol = 196부터 탐색 시작 */ 예외처리 => 10 이하의 경우 2로 안나눠지면 생성자x 탐색결과 생성자가 없는경우도 생성자x */ 2023. 1. 29.
백준 2798 python https://www.acmicpc.net/problem/2798 2798번: 블랙잭 첫째 줄에 카드의 개수 N(3 ≤ N ≤ 100)과 M(10 ≤ M ≤ 300,000)이 주어진다. 둘째 줄에는 카드에 쓰여 있는 수가 주어지며, 이 값은 100,000을 넘지 않는 양의 정수이다. 합이 M을 넘지 않는 카드 3장 www.acmicpc.net """ 2798 """ N, M = map( int, input().split() ) lst = list( map( int, input().split() ) ) a = max(lst) aidx = lst.index(a) lst[aidx] = 0 b = max(lst) bidx = lst.index(b) lst[bidx] = 0 c = max(lst) lst[bidx.. 2023. 1. 26.
백준 python 백준 2525 """ 2525 """ import sys nTime, nMin = map(int, sys.stdin.readline().split()); cookMin = int(sys.stdin.readline()); tm = (60 * nTime + cookMin + nMin); if(tm > 1439) : tm %= 1440 print(tm // 60, end = " "); print(tm % 60); 백준 1110 import sys N = int(sys.stdin.readline()); tmN = N; first = 0; last = 0; cnt = 0; while 1: first = N // 10 last = N % 10 N = (first + last) % 10 + last * 10 cnt .. 2023. 1. 26.