| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
不需要枚举,直接分解质因子就可以了#include <stdio.h>
#include <math.h>
#define M 13
int main()
{
int x, i, j, k, p[M], n, T;
int d, ans;
scanf("%d", &n);
k = sqrt(x = n << 1), i = 2;
int q[M] = {0}, c = 0;
while(i <= k){
if(x % i == 0){
p[c] = i;
j = 1;
do{
x /= i;
j++;
}while(x % i == 0);
k = sqrt(x);
q[c++] = j;
}
i++;
}
if(x > 1){
p[c] = x, q[c] = 2;
c++;
}
for(i = ans = 1; i < c; i++) ans *= q[i];
printf("%d\n", ans);
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator