프로그래밍/알고리즘(10)
-
Project Euler Problem5
Problem5.2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? 나의 풀이)알고리즘은 소수의 최대제곱을 찾으면 되는 것이다.특히 2와 3의 값이 중요한데5부터는 어차피 2개 이상 가지고 있는 수는 25를 넘어가버리므로5,7,11,13,17,19는 확정으로 곱해진다.2의 배수 중 20이하의 수를 구하면 16 = 2^43의 배수 중 20이하의 수는 9 = 3^2 이므로 이를 모두 곱하면 답이 된다..
2015.02.12 -
Project Euler Problem7
Problem7.By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.What is the 10001st prime number? 나의 풀이)10001번째 소수를 구하는 것.일단 소수인지를 확인하는 bool isPrime(int num); 함수를 구현했다.생각한 것이. bool flag = true; for (int i = 2; i
2015.02.05 -
Project Euler Problem6
Problem6.The sum of the squares of the first ten natural numbers is,12 + 22 + ... + 102 = 385The square of the sum of the first ten natural numbers is,(1 + 2 + ... + 10)2 = 552 = 3025Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640.Find the difference between the sum of the squares of the first one hundred natural..
2015.02.05 -
Project Euler Problem4
몇 주전에 풀다가 답이 틀려 잠깐 멈췄던 부분이 있었는데.. 1시간 가량 찾지 못했던 해답을 오늘 3분만에 풀었다.알고리즘 문제를 하루에 하나 풀어보자고 하는데.. 역시 뭐 생각만큼 쉽지는 않다. Problem4. A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.Find the largest palindrome made from the product of two 3-digit numbers. 직접 푼 알고리즘)C++환경에서 for문 2개를 써서 풀었다.999*999부터 100*100까지 비교했다.여기서 palindro..
2015.01.25