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

不知道哪里错了,大牛给点意见嘛

Posted by _yz_ at 2008-05-28 01:40:44 on Problem 1305
#include<iostream>
#include<cmath>
#include<bitset>

using namespace std;


int main(void)
{
	int aa;
	while(cin>>aa)
	{		
		int m;
		int n;
		int i;
		int cnt=0;	
		bitset<1000001> b;
		b.set(0);

		for(m=1;m<(int)sqrt((double)aa)+1;m++)		
			for(n=1;n<m;n++)
				if((m*m+n*n)>aa)break;
				else if( (m%2==0&&n%2==0)||(m%2&&n%2)||(m%n==0&&n!=1) )	continue;				
				else
				{
					cnt++;					
					int k=m*m+n*n;
					for(i=1;i<=aa/k;i++)
					{
						b[i*k]=1;
						b[i*2*m*n]=1;
						b[i*(m*m-n*n)]=1;
					}
				}
		cout<<cnt<<" ";
		cnt=0;		
		for(i=1;i<=aa;i++)
			if(b[i]==0)cnt++;
			else b[i]=0;
		cout<<cnt;					
		
	
	}
	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