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

完全可以不用STL,直接模拟就好了。贴个代码。。

Posted by bingshen at 2010-11-20 20:51:32 on Problem 3032
#include<stdio.h>
#include<string.h>

int order[14];

void init()
{
	int i;
	order[1]=2;
	for(i=2;i<=13;i++)
		order[i]=order[i-1]+i+1;
}

int main()
{
	int n,i,j,x;
	int ans[200];
	init();
	scanf("%d",&x);
	while(x--)
	{
		scanf("%d",&n);
		memset(ans,0,sizeof(ans));
		for(i=n;i>=1;i--)
		{
			ans[order[i]]=i;
			int t=n-i+1;
			for(j=order[i]-1;j>order[i-1];j--)
			{
				if(n==i)
				{
					ans[j]=n;
				}
				else
				{
					ans[j]=ans[j+t];
				}
			}
		}
		for(i=1;i<n;i++)
			printf("%d ",ans[i]);
		printf("%d\n",ans[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