| ||||||||||
| 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 | |||||||||
why waWA的代码如下,路过者帮忙看看是哪里错了
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int f[3000],len;
int prime[2240];
bool hash[2241];
void gettable ()
{
int i,j;
memset (hash, false, sizeof (hash));
for (i = 2; i < 48; i++)
{
if (hash[i] == false)
{
for (j = 2 * i; j < 2240; j = j + i)
hash[j] = true;
}
}
j = 0;
for (i = 2; i < 2240; i++)
{
if (hash[i] == false)
prime[j++] = i;
}
// for (i = 0; i < j; i++)
// cout << prime[i] << " ";
}
__int64 getvalue (int n)
{
int i,c,l,max;
__int64 ans;
l = 0;
max = sqrt (n) + 1;
for (i = 0; prime[i] < max; i++)
{
c = 0;
while (n % prime[i] == 0)
{
n /= prime[i];
c++;
}
if (c != 0)
f[l++] = c;
}
len = l;
ans = 1;
for (i = 0; i < len; i++)
{
ans *= ((f[i] + 1) * (f[i] + 2)) * ((f[i] + 1) * (f[i] + 2));
}
ans >>= (len + len);
return ans;
}
int main ()
{
int t,n;
__int64 ans;
gettable ();
scanf ("%d",&t);
while (t--)
{
scanf ("%d",&n);
ans = getvalue (n);
printf ("%I64d\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