~cpp #include <iostream> #include <math.h> using namespace std; unsigned int factorial_factors(unsigned int); void main() { cout << "2-1000000사이의 숫자를 입력해주세요.조건에 맞지않는 숫자를 입력하면 종료됩니다.\n"; cin >> input_number; while (1) { cout << factorial_factors(input_number) << "\n"; cin >> input_number; } } unsigned int factorial_factors(unsigned int answer) { unsigned int *log_answer = (unsigned int*)malloc((answer+2)*sizeof(unsigned int)); unsigned int sum = 1; unsigned int gab; unsigned int suchEnd = (unsigned int)sqrt((double)answer); log_answer[2]=1; log_answer[3]=0; for (register unsigned int i=4; i<=answer;i+=2) { log_answer[i]=2; log_answer[i+1]=0; } for (register unsigned int i=3; i<=suchEnd; ++i) { if (0==log_answer[i]) { log_answer[i]=1; gab=i+i; for(register unsigned int j = i * i; j <= answer; j+= gab) log_answer[j] = i; ++sum; } else sum+=log_answer[i]=log_answer[i/log_answer[i]]+1; } for (register unsigned int i = suchEnd + 1; i <= answer; ++i) { if (0==log_answer[i]) { log_answer[i]=1; gab=i+i; ++sum; } else sum+=log_answer[i]=log_answer[i/log_answer[i]]+1; } free(log_answer); return sum; }