Problem The prime factors of 13195 are 5,7,13 and 29. What is the largest prime factor of the number 600851475143? 어떤 수를 소수의 곱으로만 나타내는 것을 소인수분해라 하고, 이 소수들을 그 수의 소인수라고 합니다. 예를 들면 13195의 소인수는 5, 7, 13, 29 입니다. 600851475143의 소인수 중에서 가장 큰 수를 구하세요. Java Code Python Code n, m = 600851475143,2 while m
Problem Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:1,2,3,5,8,13,21,34,55,89,… By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. 피보나치 수열의 각 항은 바로 앞의 항 두 개를 더한 것이 됩니다. 1과 2로 시작하는 경우 이 수열은 아래와 같습니다. 1, 2, 3, 5, 8, 13, 21, 3..
Problem If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3,5,6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. 10보다 작은 자연수 중에서 3 또는 5의 배수는 3, 5, 6, 9 이고, 이것을 모두 더하면 23입니다. 1000보다 작은 자연수 중에서 3 또는 5의 배수를 모두 더하면 얼마일까요? Java Code public class prob_1 { public static void main(String[] args) { int a = 3; int b = 5; int c ..
from sys import stdin from collections import Counter n = stdin.readline().rstrip() card = list(map(int, stdin.readline().split())) m = stdin.readline().rstrip() input_card = list(map(int, stdin.readline().split())) count = Counter(card) for i in input_card: if i in count: print(count[i], end=' ') else: print(0, end=' ')
문제 설명 트럭 여러 대가 강을 가로지르는 일차선 다리를 정해진 순으로 건너려 합니다. 모든 트럭이 다리를 건너려면 최소 몇 초가 걸리는지 알아내야 합니다. 다리에는 트럭이 최대 bridge_length대 올라갈 수 있으며, 다리는 weight 이하까지의 무게를 견딜 수 있습니다. 단, 다리에 완전히 오르지 않은 트럭의 무게는 무시합니다. 예를 들어, 트럭 2대가 올라갈 수 있고 무게를 10kg까지 견디는 다리가 있습니다. 무게가 [7, 4, 5, 6]kg인 트럭이 순서대로 최단 시간 안에 다리를 건너려면 다음과 같이 건너야 합니다. 경과 시간다리를 지난 트럭다리를 건너는 트럭대기 트럭 0 [] [] [7,4,5,6] 1~2 [] [7] [4,5,6] 3 [7] [4] [5,6] 4 [7] [4,5] [..
쉬운 문제를 고른 건 맞는데, 내가 이렇게 쉽게 풀 줄 몰랐지.. def solution(nums): if len(nums)/2 > len(set(nums)): return len(set(nums)) else: return len(nums)/2 가져갈 수 있는 폰켓몬 양이 종류의 개수보다 많은 경우 종류의 개수를 반환하고 아닌 경우 폰켓몬을 가져갈 수 있는 양을 반환한다.