Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

why wa

Posted by lironghua at 2008-09-07 18:00:10 on Problem 3604
WA的代码如下,路过者帮忙看看是哪里错了
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator