본문 바로가기

python-algorithm1402

백준 29766 DKSH 찾기 https://www.acmicpc.net/problem/29766 29766번: DKSH 찾기 첫째 줄에 문자열이 입력된다. 문자열의 길이는 $1\,000$을 넘지 않는다. www.acmicpc.net 1 2 3 4 5 6 7 8 def solution(s): return s.count('DKSH') if __name__ == '__main__': s = input() print(solution(s)) cs Python 문자열에는 count 메소드가 있어서 특정 문자열이 몇번 포함됐는지 셀 수 있습니다. 2023. 11. 16.
백준 30328 Java Warriors https://www.acmicpc.net/problem/30328 30328번: Java Warriors Jerry has earned acclaim as a renowned coach in the highly competitive realm of the International Collegiate Programming Contest (ICPC). His coaching prowess is exemplified by his unique approach — meticulously training his students to excel in ICPC comp www.acmicpc.net 1 2 3 4 5 6 7 8 def solution(n): return n * 4000 if __name__ == '__.. 2023. 11. 16.
백준 30664 Loteria Falha https://www.acmicpc.net/problem/30664 30664번: Loteria Falha Para cada caso de teste haverá uma linha na saída. Caso o número identificador do cartão seja um múltiplo de 42, imprima “PREMIADO”. Caso contrário, imprima “TENTE NOVAMENTE”. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 def solution(n): if n % 42 == 0: return 'PREMIADO' else: return 'TENTE NOVAMENTE' if __name__ == '__main__': while T.. 2023. 11. 16.
백준 2751 수 정렬하기 2 링크 : https://www.acmicpc.net/problem/2751 2751번: 수 정렬하기 2 첫째 줄에 수의 개수 N(1 ≤ N ≤ 1,000,000)이 주어진다. 둘째 줄부터 N개의 줄에는 수가 주어진다. 이 수는 절댓값이 1,000,000보다 작거나 같은 정수이다. 수는 중복되지 않는다. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 ㅔㅛimport sys if __name__ == '__main__': n = int(sys.stdin.readline()) ans = [0] * 2000001 for i in range(n): ans[int(sys.stdin.readline())+1000000] = 1 for i in range(2000001): if ans[i] !.. 2023. 9. 12.
백준 28444 HI-ARC=? 링크 : https://www.acmicpc.net/problem/28444 28444번: HI-ARC=? 첫째 줄에 각 문자에 들어갈 값 $H, I, A, R, C$ ($0 \leq H,I,A,R,C \leq 100$, $H,I,A,R,C$는 정수) 가 공백을 사이에 두고 순서대로 주어진다. www.acmicpc.net 1 2 3 4 5 6 7 8 def sol(nums): return nums[0] * nums[1] - nums[2] * nums[3] * nums[4] if __name__ == '__main__': nums = list(map(int, input().split())) print(sol(nums)) Colored by Color Scripter cs 사용된 알고리즘 : X 리스트로 입.. 2023. 9. 12.
백준 28701 세제곱의 합 링크 : https://www.acmicpc.net/problem/28701 28701번: 세제곱의 합 $a$의 제곱은 $a$를 두 번 곱한 수로, $a^2$으로 표현합니다. $a^2 = a \times a$입니다. 또한, $a$의 세제곱은 $a$를 세 번 곱한 수로, $a^3$으로 표현합니다. $a^3 = a \times a \times a$ 입니다. www.acmicpc.net 1 2 3 4 5 6 7 def sol(n): print(n*(n+1)//2) print((n*(n+1)//2)**2) print((n*(n+1)//2)**2) if __name__ == '__main__': n = int(input()) sol(n) cs 사용된 알고리즘 : X 알고리즘 보다 수학적 정의를 내리시는게 조금 더.. 2023. 9. 12.
백준 2393 Rook 링크 : https://www.acmicpc.net/problem/2393 2393번: Rook The rook art, exactly as shown below, with no extra blank spaces. In particular, a line must not end with a blank space. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 def sol(): print(" ___ ___ ___") print(" | |__| |__| |") print(" | |") print(" \\_________/") print(" \\_______/") print(" | |") print(" | |") print(" | |") print(" .. 2023. 9. 12.
백준 28235 코드마스터 2023 링크 : https://www.acmicpc.net/problem/28235 28235번: 코드마스터 2023 송도고등학교에서 주최하는 첫 중고등학생 대상 알고리즘 대회, "코드마스터 2023"이 열렸다! 이 대회가 중고등학생들에게 인기 있는 알고리즘 대회이자 오프라인 이벤트로서 자리매김할 수 있 www.acmicpc.net 사용된 알고리즘 : X 간단한 입력 후 출력 입니다. 딕셔너리를 사용했습니다! 1 2 3 4 5 6 7 8 9 10 11 12 def sol(guho): guhos ={ 'SONGDO':'HIGHSCHOOL', 'CODE': 'MASTER', '2023': '0611', 'ALGORITHM': 'CONTEST' } return guhos[guho] if __name__ == '__m.. 2023. 9. 11.
leetcode 2798. Number of Employees Who Met the Target https://leetcode.com/problems/number-of-employees-who-met-the-target/description/ Number of Employees Who Met the Target - LeetCode Can you solve this real interview question? Number of Employees Who Met the Target - There are n employees in a company, numbered from 0 to n - 1. Each employee i has worked for hours[i] hours in the company. The company requires each employee to work for leetcode.c.. 2023. 8. 4.
leetcode 2744. Find Maximum Number of String Pairs https://leetcode.com/problems/find-maximum-number-of-string-pairs/description/ Find Maximum Number of String Pairs - LeetCode Can you solve this real interview question? Find Maximum Number of String Pairs - You are given a 0-indexed array words consisting of distinct strings. The string words[i] can be paired with the string words[j] if: * The string words[i] is equal to the rev leetcode.com 1 .. 2023. 7. 13.
leetcode 2769. Find the Maximum Achievable Number https://leetcode.com/problems/find-the-maximum-achievable-number/description/ - LeetCode Can you solve this real interview question? - You are given two integers, num and t. An integer x is called achievable if it can become equal to num after applying the following operation no more than t times: * Increase or decrease x by 1, and simultaneou leetcode.com 1 2 3 class Solution: def theMaximumAch.. 2023. 7. 13.
leetcode 2739. Total Distance Traveled https://leetcode.com/problems/total-distance-traveled/description/ Total Distance Traveled - LeetCode Can you solve this real interview question? Total Distance Traveled - A truck has two fuel tanks. You are given two integers, mainTank representing the fuel present in the main tank in liters and additionalTank representing the fuel present in the addition leetcode.com 1 2 3 4 5 6 7 8 9 10 11 12.. 2023. 7. 7.