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

请高手指导我的WA程序,有什么测试数据吗? 0 2,000,000,000 的结果是不是311?

Posted by impala at 2006-10-05 19:49:11 on Problem 3005
#include "iostream"
#include "math.h"
using namespace std;



main()
{
	bool measure[45000]={0};
	long m[4800]; 
	int lm;

	register long i, j, k;
	i=3;
	
	while (i<=44721)
	{
		k=2;
		while (k<=int(sqrt(i)))
		{
			while (!measure[k]) k++;
			if (!(i%k))
			{
				goto step1;
			}
			k++;
		}
		measure[i]=1;
step1:	i+=2;
	}
	measure[2]=1;
	measure[1]=1;
	measure[0]=1;
	measure[3]=1;
	lm=0;
	for (i=2;i<=44721;i++)
	{
		if (measure[i]) 
		{
			lm++;
			m[lm]=i;
		}			
	}	
	measure[2]=1;
	measure[1]=1;
	measure[0]=1;
	long xl, xh;
	int n;
	register long x;
	long tot;
	cin>>n;
	while (n)
	{
		cin>>xl>>xh;
		tot=0;
		long a,b;
		tot=0;
		for (a=1;a<=140;a++)
		{
			i=1;
			while ((i<=lm)&&(m[i]<=int(sqrt(xh))))
			{
				b=m[i]-a;
				x=1;
				k=1;
				int n=0;
				while ((x<=xh)&&(x>0)&&(k<=44721)&&(k>0)&&(measure[k]))
				{
						if (x>=xl&&x<=xh&&n>=3) 
						{
							tot++;
							n++;
							k=a*k+b;
							x=x*k;
						}
						else 
						{
							n++;	
							k=a*k+b;
							x=x*k;
						}
				}
				i++;
			}
		}
		cout<<tot<<endl;
		n--;
	}
	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