#include <iostream>
#define MAX 10001
using namespace std;
bool prime[ MAX ] = {false};
int r[ MAX ];
int ff[ MAX ] , kf;
bool v[ MAX ];
int rank[ MAX ];
__int64 ans[MAX];
int k;
void factor (int n)
{
int i;
for (i = 2 ; i <= n ; ++ i)
{
while (n % i == 0)
{
n /= i;
r[ i ] ++;
}
if (n == 1)
break;
if (prime[ n ])
{
r[ n ] ++;
break;
}
}
}
int main()
{
int i , j;
int n , g;
__int64 tt;
kf = 0;
for (i = 2 ; i <= MAX ; ++ i)
prime[ i ] = true;
for (i = 2 ; i <= MAX ; ++ i)
if (prime[ i ])
{
ff[++ kf] = i;
rank[ i ] = kf;
for (j = i + i ; j <= MAX ; j += i)
prime[ j ] = false;
}
while (scanf ("%d" , &n) , n)
{
g = 2;
memset (r , 0 , sizeof (r));
for (i = 2 ; i <= n ; ++ i)
{
if (prime[ i ])
{
r[ i ] ++;
if (i > g)
g = i;
}
else
factor (i);
}
k = 1;
ans[ 1 ] = 1;
int tmp = 0;
for (i = 1 ; i <= rank[ g ] ; ++ i)
{
tt = (r[ff[ i ]] << 1) + 1;
for (j = 1 ; j <= k ; ++ j)
{
ans[ j ] = ans[ j ] * tt + tmp;
tmp = ans[ j ] / 10000 , ans[ j ] %= 10000;
}
while (tmp)
ans[++ k] = tmp % 10000 , tmp /= 10000;
}
printf ("%I64d" , ans[ k ]);
for (i = k - 1 ; i > 0 ; -- i)
printf ("%04I64d" , ans[ i ]);
printf ("\n");
}
return 0;
}
这题其实是求(n!)^2的约数的个数,注意要大数处理。其余的自己去算吧,orz~~~~~~