U E D R , A S I H C RSS

Ugly Numbers/송지훈

  • . 1500개리 배때까 1부
는 방.
  • 2, 3, 5라는 딩.

드. 900는데 2 리고,
1000는데 7 린다...

1500꺼 구... 76 린다...

#include <iostream>
#include <ctime>
using std::cout;
using std::cin;
using std::endl;
using std::clock_t;

#define LIMIT 1500                      // 배 

int main() {
	int arr[LIMIT] = {0}, num, index = 0, target;
	clock_t start,end;              // 려고 .
	target = 1500;                  // 1500 를 구는 변.

	start = clock();                //  .
	for(int i = 1;arr[target-1] == 0;i++) {
		num = i;
		while((num % 2) == 0) {
			num /= 2;
		}
		while((num % 3) == 0) {
			num /= 3;
		}
		while((num % 5) == 0) {
			num /= 5;
		}
		if(num == 1) {          // 2, 3, 5 로 나는데 몫 1면 못난.
			arr[index] = i; // 몫 1 면 그냥 .
			index++;
		}
	}
	end = clock();                  // 끝난 .

	cout << "Run time = " << (double)(end-start)/CLK_TCK << endl
		 << arr[target-1] << endl;
	return 0;
}

느낀

다른 방 고리로 그냥 막 배 때려
sorting 는 방법 겠다 라는 것 느낌.

겠다고
방법 남.

2, 3, 5 라는 것 떤 법 내려고
30개까 그냥 방법로 구...


드보 는 방법
만 그냥 막 때려 나... ...
결국 데...

... 괜 렵다.
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:19
Processing time 0.0099 sec