본문 바로가기

백준1056

백준 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.
백준 26040 특정 대문자를 소문자로 바꾸기 https://www.acmicpc.net/problem/26040 26040번: 특정 대문자를 소문자로 바꾸기 알파벳 대소문자로 구성된 문자열 A가 주어진다. 한 개 이상의 알파벳 대문자가 공백으로 구분된 문자 목록 B가 주어진다. 문자 목록 B에는 중복된 대문자가 존재하지 않는다. 문자 목록 B에 존재 www.acmicpc.net 1 2 3 4 5 6 7 8 9 def sol(s, list_s): for capital_letter in list_s: s = s.replace(capital_letter, capital_letter.lower()) return s if __name__ == '__main__': s = input() list_s = list(input().split()) print(sol.. 2022. 12. 7.
백준 6976 Divisibility by 11 https://www.acmicpc.net/problem/6976 6976번: Divisibility by 11 For each positive integer in the input, the output consists of a series of numbers formed as a digit is deleted and subtracted, followed by a message indicating whether or not the original number is divisible by 11. Outputs for different positive integers www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 def sol(n): start_.. 2022. 12. 7.
백준 5940 Math Practice https://www.acmicpc.net/problem/5940 5940번: Math Practice One lovely afternoon, Bessie's friend Heidi was helping Bessie review for her upcoming math exam. Heidi presents two integers A (0 2022. 12. 7.
백준 9713 Sum of Odd Sequence https://www.acmicpc.net/problem/9713 9713번: Sum of Odd Sequence First line of the input contains T, the number of test cases. Each test case contains a single integer N. N is between 1 and 100. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 def sol(n): answer = (n//2+1)**2 return answer if __name__ == '__main__': t = int(input()) for _ in range(t): n = int(input()) print(sol(n)) cs 홀수의 합 구하는 공식: n^2 2022. 12. 6.
백준 26041 비슷한 전화번호 표시 https://www.acmicpc.net/problem/26041 26041번: 비슷한 전화번호 표시 n개의 전화번호가 공백으로 구분된 문자열 A가 주어진다. 문자열 A에는 중복된 전화번호가 존재할 수 있다. 추가로, 하나의 전화번호 B가 주어진다. 전화번호는 문자 ‘1’ ~ 문자 ‘9’로 이루어 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 def sol(s,target): answer = 0 for i in s: if i!=target and i.startswith(target): answer+=1 return answer if __name__ == '__main__': phone_numbers = list(map(str, input().split())) target = i.. 2022. 12. 6.
백준 6500 랜덤 숫자 만들기 https://www.acmicpc.net/problem/6500 6500번: 랜덤 숫자 만들기 입력은 여러 개의 테스트 케이스로 이루어져 있다. 각 테스트 케이스는 한 줄이며, a0을 포함하고 있다. (0 < a0 < 10000) 숫자가 네 자리가 아닌 경우에는, 앞에 0을 추가해 네 자리로 만들어져 있다. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 def sol(s,n): answer = [s] while True: s = str(int(s)**2).zfill(n*2) s = s[n//2:2*n-n//2] if s not in answer: answer.append(s) else: return len(answer) if __name__.. 2022. 12. 6.
백준 7120 String https://www.acmicpc.net/problem/7120 7120번: String It sometimes happens that a button on the computer keyboard sticks and then in the printed text there are more than one identical letters. For example, the word "piano" can change into "ppppppiaanooooo". Your task is to write a program that corrects these www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 def sol(s): answer = '' for i in range(1,len(s)): if s.. 2022. 12. 5.
백준 6438 Reverse Text https://www.acmicpc.net/problem/6438 6438번: Reverse Text In most languages, text is written from left to right. However, there are other languages where text is read and written from right to left. As a first step towards a program that automatically translates from a left-to-right language into a right-to-left www.acmicpc.net ㅇ 1 2 3 4 5 6 7 8 9 10 11 12 def sol(s): s = list(reversed(s.split()).. 2022. 12. 5.
백준 13234 George Boole https://www.acmicpc.net/problem/13234 13234번: George Boole George Boole was an English mathematician, educator, philosopher who was born in 1815, 200 years ago. He was the first professor of mathematics at Queen's College, Cork (now University College Cork (UCC)) and is known as the inventor of boolean arithmetic: www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 def sol(s): s = list(s.split()) s.. 2022. 12. 5.
백준 15080 Every Second Counts https://www.acmicpc.net/problem/15080 15080번: Every Second Counts Meredith runs a taxi service called Ruber which offers rides to clients in small towns in western Pennsylvania. She wants to get every possible dime out of people who use her taxis, so her drivers charge a flat fee not per minute but per second. It’s imp www.acmicpc.net 1 2 3 4 5 6 7 8 9 if __name__ == '__main__': start_hh, start_.. 2022. 12. 4.