标签:
Description
Input
Output
Sample Input
Sample Output
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int main() { int t,n,i,p,sum,s[5005],cut; while (~scanf("%d",&t)) { while (t--) { p=2; scanf("%d",&n); memset(s,0,sizeof(s)); sum=0; while (n-sum>3) { cut=0; for (i=1;i<=n;i++) { if(s[i]) continue; cut++; if (cut==p) {sum++;s[i]=1;cut=0;} } if (p==3) p--; else p++; } cut=0; for (i=1;i<=n;i++) if (!s[i]) { cut++; if (cut!=n-sum) printf("%d ",i); else printf("%d\n",i);} } } }
标签:
原文地址:http://www.cnblogs.com/pblr/p/4698848.html