Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
完全可以不用STL,直接模拟就好了。贴个代码。。#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator