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 vince4053040 at 2009-11-29 16:28:18 on Problem 1218
#include<iostream>
using namespace std;
int p;
int main()
{
	int times;
	int n,i;
	cin>>times;
	while(times--)
	{
		bool a[102]={0};//1表示开 0表示关
		int m=0;
		cin>>p;
		for(i=1;i<=p;i++)
		{
			for(n=1;n*i<=p;n++)
			{
				if(a[n*i]==1)a[n*i]=0;
				if(a[n*i]==0)a[n*i]=1;//改这
                cout<<a[n*i]<<endl;
			}
		}
		for(i=1;i<=p;i++)
		{
			if(a[i]==1)
				m++;
		}
		//cout<<m<<endl;
	}
	return 0;
}






#include<iostream>
using namespace std;
int p;
int main()
{
	int times;
	int n,i;
	cin>>times;
	while(times--)
	{
		bool a[102]={0};//1表示开 0表示关
		int m=0;
		cin>>p;
		for(i=1;i<=p;i++)
		{
			for(n=1;n*i<=p;n++)
			{
				if(a[n*i]==1)a[n*i]=0;
				else a[n*i]=1;
                cout<<a[n*i]<<endl;
			}
		}
		for(i=1;i<=p;i++)
		{
			if(a[i]==1)
				m++;
		}
		//cout<<m<<endl;
	}
	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