Problem 5 Study/ProjectEuler 2016. 10. 30. 21:42 Problem 5.1 ~ 10 사이의 어떤 수로도 나누어 떨어지는 가장 작은 수는 2520입니다.그러면 1 ~ 20 사이의 어떤 수로도 나누어 떨어지는 가장 작은 수는 얼마입니까? #include <iostream> using namespace std; typedef unsigned int uint; #define N 20 // 1~20까지 약수들을 구한다 // 최소공배수를 구하기 위해 구해진 약수의 갯수가 기존값보다 크면 덮어씌운다. void main() { int arr[N + 1] = { 0 }; int result = 1; int temp = 0; int temp2 = 0; for( int i = 2; i <= N; i++ ) { temp2 = i; for( int j = 2; j <= temp2; j++ ) { while( temp2 % j == 0 ) { temp++; temp2 /= j; } if( arr[j] < temp ) arr[j] = temp; temp = 0; } } for( int i = 1; i <= N; i++ ) { result *= pow( i, arr[i] ); } printf( "%d\n", result ); } 정답: 232792560 공유하기 게시글 관리 Bera의 개발 이야기 저작자표시 (새창열림) 'Study > ProjectEuler' 카테고리의 다른 글 Problem 7 (0) 2016.10.30 Problem 6 (0) 2016.10.30 Problem 4 (0) 2016.10.30 Problem 3 (0) 2016.10.30 Problem 2 (0) 2016.10.30 Posted by BeraPP ,