본문 바로가기

python-algorithm1402

백준 30999 민주주의 https://www.acmicpc.net/problem/30999 30999번: 민주주의 월간 향유회에서는 민주주의적 다수결 투표 방식으로 문제의 출제 여부를 정한다. 즉, $N$개의 문제 후보마다 $M$명의 출제위원이 찬반 의견을 내고, 과반수의 찬성을 얻은 문제가 출제된다. 이때 www.acmicpc.net 1 2 3 4 5 6 7 8 if __name__ == '__main__': n, m = map(int, input().split()) answer = 0 for i in range(n): s = input() if s.count('O') > m//2: answer += 1 print(answer) cs 2024. 4. 16.
백준 31403 https://www.acmicpc.net/problem/31403 31403번: $A + B - C$ JavaScript에서 $+, -$은 수에 대해서는 일반적인 의미의 덧셈 뺄셈의 의미를 가지고 있습니다. 하지만 문자열에 대해서 $+$는 두 문자열을 이어붙이라는 의미이고, $-$는 양쪽 문자열을 수로 해석한 www.acmicpc.net 12345678910def sol(a, b, c): print(int(a) + int(b) - int(c)) print(int(a+b) - int(c)) if __name__ == '__main__': a = input() b = input() c = input() sol(a, b, c)cs 2024. 4. 16.
백준 30402 감마선을 맞은 컴퓨터 https://www.acmicpc.net/problem/30402 30402번: 감마선을 맞은 컴퓨터 춘배와 나비, 영철은 어느 날 지구에 나타난 UFO에게 감마선을 맞을 뻔했다. 다행히도 감마선은 행복하게 뒹굴고 있던 고양이들 옆에 있던 컴퓨터에 맞았지만, 이로 인해 컴퓨터에 저장된 춘배와 www.acmicpc.net 12345678910111213if __name__ == '__main__': for i in range(15): s = input() if 'w' in s: print('chunbae') break elif 'b' in s: print('nabi') break elif 'g' in s: print('yeongcheol') break cs 2024. 4. 16.
백준 31606 果物 (Fruit) https://www.acmicpc.net/problem/31606 31606번: 果物 (Fruit) リンゴが X 個,ミカンが Y 個,バナナが 3 個ある.リンゴとミカンとバナナが合わせて何個あるかを求めよ. www.acmicpc.net 1234567891011def sol(x, y): return x + y + 3 if __name__ == '__main__': x = int(input()) y = int(input()) print(sol(x, y)) cs 2024. 4. 15.
백준 31610 飴の袋詰め (Drops Packing) https://www.acmicpc.net/problem/31610 31610번: 飴の袋詰め (Drops Packing) 1 個 A 円の飴を B 個と,C 円の袋を 1 つ買う.合計金額はいくらか求めよ. www.acmicpc.net 1234567891011def sol(a, b, c): return a * b + c if __name__ == '__main__': a = int(input()) b = int(input()) c = int(input()) print(sol(a, b, c)) cs 2024. 4. 15.
백준 31611 火曜日 (Tuesday) https://www.acmicpc.net/problem/31611 31611번: 火曜日 (Tuesday) 今日の X 日後が火曜日であるならば 1 を,そうでないならば 0 を出力せよ. 答え以外は何も出力しないこと.(入力を促す文章なども出力しないこと.) www.acmicpc.net 1234567891011def sol(x): if x % 7 == 2: return 1 else: return 0 if __name__ == '__main__': x = int(input()) print(sol(x)) cs 2024. 4. 15.
백준 31614 分 (Minutes) https://www.acmicpc.net/problem/31614 31614번: 分 (Minutes) 整数 H, M が与えられる. H 時間 M 分が何分かを求めよ. www.acmicpc.net 123456789def sol(h, m): return h * 60 + m if __name__ == '__main__': h = int(input()) m = int(input()) print(sol(h, m)) cs 2024. 4. 15.
백준 31654 Adding Trouble https://www.acmicpc.net/problem/31654 31654번: Adding Trouble Your friend Bob is really bad at adding numbers, and he’d like some help to make sure he’s doing it correctly! Can you help Bob make sure he is adding correctly? Given 3 integers $A$, $B$, $C$, make sure that $A + B = C$, and that Bob indeed added $A$ www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 def sol(a, b, c): if a + b == c: return "corr.. 2024. 4. 15.
백준 31450 Everyone is a winner https://www.acmicpc.net/problem/31450 31450번: Everyone is a winner Your friend is a kindergarten teacher. Since the Olympic Games in Paris are approaching, he wants to teach the kids about different aspects of sports competitions. As part of this idea, he plans to have one day when kids receive medals for their behaviour www.acmicpc.net 1234567891011def sol(m, k): if m % k == 0: return "Yes" els.. 2024. 3. 31.
백준 31429 SUAPC 2023 Summer https://www.acmicpc.net/problem/31429 31429번: SUAPC 2023 Summer SUAPC 2023 Summer에서 $N$등을 한 팀이 푼 문제 수와 푼 문제들의 페널티의 합을 공백으로 구분하여 출력한다. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 def sol(n): answer = {1: [12, 1600] , 2: [11, 894] , 3: [11, 1327] , 4: [10, 1311] , 5: [9, 1004] , 6: [9, 1178] , 7: [9, 1357] , 8: [8, 837] , 9: [7, 1055] , 10: [6, 556] , 11: [6, 773]} return an.. 2024. 2. 26.
leetcode 3038. Maximum Number of Operations With the Same Score I https://leetcode.com/problems/maximum-number-of-operations-with-the-same-score-i/description/ LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1 2 3 4 5 6 7 8 9 10 11 class Solution: def maxOperations(self, nums: List[int]) .. 2024. 2. 18.
leetcode 1941. Check if All Characters Have Equal Number of Occurrences https://leetcode.com/problems/check-if-all-characters-have-equal-number-of-occurrences/description/ LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1 2 3 4 5 6 7 8 9 class Solution: def areOccurrencesEqual(self, s: str) -> .. 2024. 2. 17.