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

喝水到100,留个爪印~~菜鸟一只,让您笑了……

Posted by wsj19911101 at 2010-11-24 23:42:18 on Problem 3032
#include <iostream>
using namespace std;
int a[13];
int main()
{
	int n,m;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>m;
		memset(a,0,sizeof(a));
		int k=2,p=-1;
		for(int j=1;j<=m;j++)
		{
			int n=0;
			while(n!=k)
		    {
				p=(p+1)%m;
				if(a[p]==0)n++;
			}
			a[p]=k-1;
			k++;
		}
		for(int j=0;j<m-1;j++)cout<<a[j]<<' ';
		cout<<a[m-1]<<endl;
	}
}

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