본문 바로가기

python-algorithm1413

codeforces 50A - Domino piling 50A - Domino piling Problem - 50A - Codeforces codeforces.com 1 2 3 4 5 6 7 8 9 def sol(m, n): answer = (m * n) // 2 return answer if __name__ == '__main__': m, n = map(int, input().split()) print(sol(m, n)) Colored by Color Scripter cs 2023. 1. 25.
codeforces 1772A - A+B? https://codeforces.com/problemset/problem/1772/A Problem - 1772A - Codeforces codeforces.com 1 2 3 4 5 6 if __name__ == '__main__': t = int(input()) for _ in range(t): s = input() print(eval(s)) cs 2023. 1. 25.
codeforces 1760A - Medium Number https://codeforces.com/problemset/problem/1760/A Problem - 1760A - Codeforces codeforces.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14 from statistics import median def sol(nums): answer = median(nums) return answer if __name__ == '__main__': n = int(input()) for _ in range(n): nums = list(map(int, input().split())) print(sol(nums)) Colored by Color Scripter cs 2023. 1. 25.
codeforces 1742A - Sum https://codeforces.com/problemset/problem/1742/A Problem - 1742A - Codeforces codeforces.com 1 2 3 4 5 6 7 8 9 10 11 12 13 def sol(nums): if sum(nums) - max(nums) == max(nums): return 'YES' else: return 'NO' if __name__ == '__main__': n = int(input()) for _ in range(n): nums = list(map(int, input().split())) print(sol(nums)) Colored by Color Scripter cs 2023. 1. 25.
codeforces 133A - HQ9+ https://codeforces.com/problemset/problem/133/A Problem - 133A - Codeforces codeforces.com 1 2 3 4 5 6 7 8 9 10 11 def sol(s): if 'H' in s or 'Q' in s or '9' in s: return 'YES' else: return 'NO' if __name__ == '__main__': s = input() print(sol(s)) Colored by Color Scripter cs 2023. 1. 25.
codeforces 158A - Next Round https://codeforces.com/problemset/problem/158/A Problem - 158A - Codeforces codeforces.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 from bisect import bisect_right, bisect_left def sol(nums, n, k): nums.sort() if nums[-k] != 0: answer = (n - bisect_left(nums, nums[-k])) else: answer = n-nums.count(0) return answer if __name__ == '__main__': n, k = map(int, input().split()) nums = list(map(int, .. 2023. 1. 25.
백준 26560 Periods https://www.acmicpc.net/problem/26560 26560번: Periods Eric gets distracted so sometimes he forgets to put periods at the end of his sentences. To help him out, you are to put a period at the end of his sentences if the period is not already present. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 def sol(s): if s[-1] != '.': return s + '.' else: return s if __name__ == '__main__': n = int(input()).. 2023. 1. 24.
leetcode 1684. Count the Number of Consistent Strings https://leetcode.com/problems/count-the-number-of-consistent-strings/description/ Count the Number of Consistent Strings - LeetCode Count the Number of Consistent Strings - You are given a string allowed consisting of distinct characters and an array of strings words. A string is consistent if all characters in the string appear in the string allowed. Return the number of consistent st leetcode... 2023. 1. 22.
leetcode 58. Length of Last Word https://leetcode.com/problems/length-of-last-word/description/ Length of Last Word - LeetCode Length of Last Word - Given a string s consisting of words and spaces, return the length of the last word in the string. A word is a maximal substring consisting of non-space characters only. Example 1: Input: s = "Hello World" Output: 5 Explanation: Th leetcode.com 1 2 3 4 class Solution: def lengthOfL.. 2023. 1. 21.
leetcode 2404. Most Frequent Even Element https://leetcode.com/problems/most-frequent-even-element/description/ Most Frequent Even Element - LeetCode Most Frequent Even Element - Given an integer array nums, return the most frequent even element. If there is a tie, return the smallest one. If there is no such element, return -1. Example 1: Input: nums = [0,1,2,2,4,4,1] Output: 2 Explanation: The even leetcode.com 1 2 3 4 5 6 7 8 9 10 11.. 2023. 1. 19.
leetcode 2465. Number of Distinct Averages https://leetcode.com/problems/number-of-distinct-averages/description/ Number of Distinct Averages - LeetCode Number of Distinct Averages - You are given a 0-indexed integer array nums of even length. As long as nums is not empty, you must repetitively: * Find the minimum number in nums and remove it. * Find the maximum number in nums and remove it. * Calculate th leetcode.com 12345678910111213c.. 2023. 1. 19.
leetcode 2496. Maximum Value of a String in an Array https://leetcode.com/problems/maximum-value-of-a-string-in-an-array/description/ Maximum Value of a String in an Array - LeetCode Maximum Value of a String in an Array - The value of an alphanumeric string can be defined as: * The numeric representation of the string in base 10, if it comprises of digits only. * The length of the string, otherwise. Given an array strs of alphanumeric leetcode.co.. 2023. 1. 19.