题很简单,STL中queue的基本使用。

#include <bits/stdc++.h>
using namespace std; int N,num; int main()
{
scanf("%d",&N);
while (N--) {
scanf("%d",&num);
if (num<=3) {
for (int i=1;i<num;i++) {
printf("%d ",i);
}
printf("%d\n",num);
continue;
} queue<int>q;
for (int i=1;i<=num;i++) {
q.push(i);
}
int top=num,cnt=1;
while (true) {
// printf("IN\n");
while (cnt<top+1) {
if (cnt%2!=0) {
// printf("%d\n",q.front());
q.push(q.front());
}
q.pop();
cnt++;
} if (q.size()<=3) {
break;
}
// printf("%d\n",q.size());
top=q.size();
cnt=1; while (cnt<top+1) {
if (cnt%3!=0) {
// printf("%d\n",q.front());
q.push(q.front());
}
q.pop();
cnt++;
} if (q.size()<=3) {
break;
}
top=q.size();
cnt=1;
} while (q.size()>1) {
printf("%d ",q.front());
q.pop();
}
printf("%d\n",q.front());
}
return 0;
}

最新文章

  1. 修改php.ini以达到 屏蔽错误信息
  2. Find Minimum in Rotated Sorted Array II
  3. why does angular js rock
  4. openVPN使用
  5. 用Java socket (TCP通信模型)实现一个简单的web 服务器
  6. php 加载函数 __autoload(), spl_autoload_register()
  7. 無心插柳的Linux學習者代言人——蔡德明
  8. 《STL源代码剖析》---stl_alloc.h阅读笔记
  9. 在magento中定义static block
  10. wpf mvvm datagrid DataGridTemplateColumn的绑定无效的可能原因之一!
  11. spring 注解模式 详解
  12. python继承和多态
  13. xshell 5中文破解版下载
  14. OpenEXR的读取机制
  15. Pandas新建一个DataFrame
  16. yaf 整理札记
  17. k8s secret
  18. 「6月雅礼集训 2017 Day4」寻找天哥
  19. Mui 选项卡 tab 高度 没有自适应....
  20. Python如何利用多核处理器

热门文章

  1. please execute the cleanup command
  2. (转)KMP算法
  3. No serializer found for class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor
  4. 整理收集的一些常用java工具类
  5. IntelliJ IDEA 2017.3尚硅谷-----创建动态的 Java Web
  6. 同一域名的ASP.NET网站实现Session共享
  7. Apache Kafka(五)- Safe Kafka Producer
  8. Linux - Shell - cut: 低配 awk
  9. SpringBoot获取http请求参数的方法
  10. drc实现