본문 바로가기

백준1054

백준 5341 Pyramids https://www.acmicpc.net/problem/5341 5341번: Pyramids The input will be a sequence of integers, one per line. The end of input will be signaled by the integer 0, and does not represent the base of a pyramid. All integers, other than the last (zero), are positive. www.acmicpc.net 1 2 3 4 5 6 7 8 9 def sol(n): return int(n*(n+1)/2) if __name__ == '__main__': while 1: n = int(input()) if n == 0: bre.. 2022. 12. 17.
백준 26489 Gum Gum for Jay Jay https://www.acmicpc.net/problem/26489 26489번: Gum Gum for Jay Jay You are lost in the museum and keep walking by a giant rock head that says “gum gum for jay jay” each time you walk by. Print out the number of times you have walked by the giant rock head after reading in the data file. www.acmicpc.net 1 2 3 4 5 6 7 8 9 if __name__ == '__main__': cnt = 0 while 1: try: s = input() cnt += 1 except:.. 2022. 12. 17.
백준 26057 Большой удой https://www.acmicpc.net/problem/26057 26057번: Большой удой В финал соревнования по удою прошли Архип и Бронислав. В течение раунда каждый надоил ведро молока (возможно, неполное), посл www.acmicpc.net 1 2 3 4 5 6 7 8 def sol(l, t): return t - (l - t) if __name__ == '__main__': l = int(input()) t = int(input()) print(sol(l,t)) cs 단순 사칙연산입니다. 2022. 12. 13.
백준 11008 복붙의 달인 https://www.acmicpc.net/problem/11008 11008번: 복붙의 달인 한신이는 대학교에서 "복붙의 달인"으로 유명하다. 한신이는 타이핑 속도가 느리기 때문에 대학에서 가능한 모든 일을 복붙으로 해결한다. 그는 n개의 문자를 입력하는데 있어서 n초의 시간 www.acmicpc.net 1 2 3 4 5 6 7 8 9 def sol(origin_string, clipboard_string): origin_string = origin_string.replace(clipboard_string,'*') return len(origin_string) if __name__ == '__main__': n = int(input()) for _ in range(n): origin_string, cl.. 2022. 12. 13.
백준 16360 Go Latin https://www.acmicpc.net/problem/16360 16360번: Go Latin Your program is to read from standard input. The input starts with a line containing an integer, n (1 ≤ n ≤ 20), where n is the number of English words. In the following n lines, each line contains an English word. Words use only lowercase alphabet let www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 de.. 2022. 12. 13.
백준 26307 Correct https://www.acmicpc.net/problem/26307 26307번: Correct Your best friend, Charlie, participated Taiwan Online Programming Contest (TOPC), which is a preliminary contest of the International Collegiate Programming Contest (ICPC). According to the rules, teams are ranked according to the most problems solved. Tea www.acmicpc.net 1 2 3 4 5 6 7 8 def sol(hh, mm): answer = hh*60 + mm - 9*60 return answ.. 2022. 12. 13.
백준 16208 귀찮음 https://www.acmicpc.net/problem/16208 16208번: 귀찮음 현우는 무슨 이유에선지 길이 a1, ..., an의, 총 n개의 쇠막대가 필요해졌다. 하지만 그가 가진 것은 길이 a1+...+an의 하나의 쇠막대뿐이었다. 현우는 이 막대를 직접 잘라서 원래 필요하던 n개의 쇠 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 def sol(n, nums): sum_nums = sum(nums) nums.sort() answer = 0 for i in range(n): answer += (sum_nums-nums[i])*nums[i] sum_nums -= nums[i] return answer if __name__ == '__main__'.. 2022. 12. 12.
백준 19947 투자의 귀재 배주형 https://www.acmicpc.net/problem/19947 19947번: 투자의 귀재 배주형 2020년에 학교로 복학한 주형이는 월세를 마련하기 위해서 군 적금을 깨고 복리 투자를 하려고 한다. 주형이가 하려는 투자에는 3가지 방법의 투자 방식이 있다. 1년마다 5%의 이율을 얻는 투자 ( www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 def sol(money, years): a_type, b_type, c_type = 1.05, 1.20, 1.35 dp = [0] * (years + 1) dp[0] = money for i in range(1, years + 1): if i >= 5: dp[i] = int(max(dp[i - 1] .. 2022. 12. 12.
백준 13333 Q-인덱스 https://www.acmicpc.net/problem/13333 13333번: Q-인덱스 ICPC 대학의 모든 박사과정 학생은 자신이 발표한 논문과 그 논문들의 인용횟수를 고려한 학위 취득 조건을 만족해야 한다. 이를 위해, ICPC 대학은 q-인덱스라는 값을 정의했다. 이 인덱스는 논문 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 from bisect import bisect_left, bisect_right def sol(n, nums): start_num = max(nums) for target in range(start_num, -1, -1): bigger = n - bisect_right(nums, target) + nums.count(target).. 2022. 12. 12.
백준 14912 숫자 빈도수 https://www.acmicpc.net/problem/14912 14912번: 숫자 빈도수 자연수 n (1 ≤ n ≤ 100,000)과 한 자리 숫자 d(0~9)가 첫째 줄에 주어진다. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 def sol(start_num, target): target = str(target) answer = 0 for i in range(1,start_num+1): answer += str(i).count(target) return answer if __name__ == '__main__': start_num, target = map(int, input().split()) print(sol(start_num, target)) cs count 함수와 반복문.. 2022. 12. 10.
백준 15719 중복된 숫자 https://www.acmicpc.net/problem/15719 15719번: 중복된 숫자 1부터 N - 1까지의 정수가 하나씩 정렬되지 않은 채로 저장되어 있는 어떤 수열 A가 있다. 수열 A에 임의의 정수 M(1 ≤ M ≤ N – 1)을 넣어 크기가 N인 수열로 만들었을 때, 임의의 정수 M을 찾는 프 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 import sys def sol(n, nums): sum_nums = 0 tmp_number = '' for number in nums: if number.isnumeric(): tmp_number+=number else: sum_nums+=int(tmp_number) tmp_numb.. 2022. 12. 8.
백준 25773 Number Maximization https://www.acmicpc.net/problem/25773 25773번: Number Maximization There is only one input line; it contains an integer between 0 and 999,999 (inclusive). Assume that the input number will not have leading 0’s. Note, however, that the input can be just the value 0. www.acmicpc.net 1 2 3 4 5 6 7 def sol(s): answer = ''.join(sorted(s,reverse=True)) return answer if __name__ == '__main__': s = input.. 2022. 12. 8.