백준 15122 Forbidden Zero
https://www.acmicpc.net/problem/15122 15122번: Forbidden Zero You’re writing the positive integers in increasing order starting from one. But you’ve never learned the digit zero, and thus omit any number that contains a zero in any position. The first ten integers you write are: 1, 2, 3, 4, 5, 6, 7, 8, 9, and 11. www.acmicpc.net 123456789def solution(s): s = str(int(s) + 1) return s.replace('0','..
2023. 11. 28.
백준 16283 Farm
https://www.acmicpc.net/problem/16283 16283번: Farm 입력은 표준입력을 사용한다. 첫 번째 줄에 네 정수 a, b, n, w가 한 줄에 주어진다. 1 ≤ a ≤ 1,000, 1 ≤ b ≤ 1,000, 2 ≤ n ≤ 1,000, 2 ≤ w ≤ 1,000,000이다. www.acmicpc.net 1234567891011121314151617def solution(a, b, n, w): answer = [] for x in range(1, n): if a * x + (n - x) * b == w: answer.append((x, n - x)) if len(answer) == 1: return answer[0] else: return [-1] if __name__ == '_..
2023. 11. 28.
백준 30700 KOREA 문자열 만들기
https://www.acmicpc.net/problem/30700 30700번: KOREA 문자열 만들기 첫 번째 줄에 문자열 $S$가 주어진다. $S$는 영어 알파벳 대문자 K, O, R, E, A로만 이루어져 있으며, 문자열의 길이는 $10$ 이상 $1\,000$ 이하이다. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 def solution(s): korea = ['K','O',"R",'E',"A"] current, answer = 0, 0 for i in s: if i == korea[current]: answer += 1 current = (current + 1) % 5 return answer if __name__ == '__main__': s ..
2023. 11. 27.