构造队列
来源:互联网 发布:家族企业 知乎 编辑:程序博客网 时间:2024/05/14 02:47
方向模拟:
#include <iostream>#include <cstdio>#include <cstring>using namespace std;int a[100005];int main(){ int t;scanf("%d",&t); while(t--){ int low = 0, high = 0; int n;scanf("%d",&n); a[high++] = n; int mod = n+2; for(int i=n-1;i>=1;i--){ a[high] = i; high = (high +1)% mod; a[high] = a[low]; high = (high + 1)%mod, low = (low+1)%mod; } int ind = (low-1+n)%mod;// 一个数字重复 for(int i=low;i<low+n-1;i++){ printf("%d ",a[ind]); ind = (ind - 1 + mod)%mod; } printf("%d\n",a[ind]); } return 0;}
0 0
- 构造队列
- 构造队列
- 循环队列基本构造
- 堆构造优先级队列
- 优先队列的构造
- 两个栈构造队列
- 网易构造队列
- 网易笔试:构造队列
- [编程题] 构造队列
- [编程题] 构造队列
- 面试题-构造队列
- 构造队列问题(循环队列变形java)
- 两个栈构造一个队列 || 两个队列构造一个栈
- 04 两个栈构造队列 & 两个队列构造栈
- Java.util.Queue构造队列
- 牛客网答题笔记--构造队列
- 构造队列的算法问题
- codeforces884D(大概是构造,优先队列)
- tess4j失败的惨痛教训(日记文)
- 【MyBatis学习01】一个简单入门实例
- Ubuntu下安装Yaafe
- Python:Fatal error in launcher: Unable to create process using pip.exe
- 框架模式-MVP
- 构造队列
- 进制转换
- JDK1.6中线程池更好了,有allowCoreThreadTimeOut
- Python_05
- 第四届河南省ACM 表达式求值 栈
- 【bzoj1013】[JSOI2008]球形空间产生器sphere
- IntelliJ新建一个类的快捷键是什么?
- 求文件的MD5算法
- Mybatis+mysql动态分页查询数据案例——分页工具类(Page.java)