Sicily 1931. 卡片游戏
题目地址:1931. 卡片游戏
思路:
纯属数据结构中队列的应用,可以练练手。
具体代码如下:
#include <iostream>
#include <queue>
using namespace std; int main() {
int t;
cin >> t;
while (t--) {
int num;
cin >> num;
queue<int> store;
for (int i = ; i <= num; i++) {
store.push(i);
}
for (int i = ; i <= num; i++) {
cout << store.front() << " ";
store.pop();
int temp = store.front();
store.pop();
store.push(temp);
}
cout << endl;
} return ;
}
Sicily 1931. 卡片游戏的更多相关文章
- 【sicily】卡片游戏
卡片游戏 Time Limit: 1sec Memory Limit:32MB Description 桌上有一叠牌,从第一张牌(即位于顶面的牌)开始从上往下依次编号为1~n.当至少还剩两张牌 ...
- 卡片游戏(hdu4550)贪心
卡片游戏 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Total Submi ...
- nyoj905 卡片游戏
卡片游戏 时间限制:1000 ms | 内存限制:65535 KB 难度:1 描述 小明最近宅在家里无聊,于是他发明了一种有趣的游戏,游戏道具是N张叠在一起的卡片,每张卡片上都有一个数字,数字 ...
- NYOJ 905 卡片游戏
卡片游戏 时间限制:1000 ms | 内存限制:65535 KB 难度:1 描写叙述 小明近期宅在家里无聊.于是他发明了一种有趣的游戏.游戏道具是N张叠在一起的卡片,每张卡片上都有一个数字,数字 ...
- Java实现 LeetCode 822 翻转卡片游戏(暴力)
822. 翻转卡片游戏 在桌子上有 N 张卡片,每张卡片的正面和背面都写着一个正数(正面与背面上的数有可能不一样). 我们可以先翻转任意张卡片,然后选择其中一张卡片. 如果选中的那张卡片背面的数字 X ...
- hdu 4550 卡片游戏 贪心
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4550 题意:有n(n <= 100)个0~9之间的卡片,从左往右将卡片放到之前的卡片最左边或者最 ...
- [Swift]LeetCode822. 翻转卡片游戏 | Card Flipping Game
On a table are N cards, with a positive integer printed on the front and back of each card (possibly ...
- [LeetCode] Card Flipping Game 翻卡片游戏
On a table are N cards, with a positive integer printed on the front and back of each card (possibly ...
- 【XSY1591】卡片游戏 DP
题目描述 有标有数字为\(1\)~\(9\)的卡片各\(a_1,a_2\cdots a_9\)张,还有标有乘号的卡片\(m\)张.从中取出\(n\)张按任意顺序排列,取出两个乘号相邻和乘法在边界上的非 ...
随机推荐
- HDU_1874——最短路问题,Dijkstra算法模版
Problem Description 某省自从实行了很多年的畅通工程计划后,终于修建了很多路.不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行 ...
- 《Linear Algebra and Its Applications》-chaper1-线性方程组-线性相关性
这篇文章主要简单的记录所谓的“线性相关性”. 线性相关性的对象是向量R^n,对于向量方程,如果说x1v1 + x2v2 + …+xmvm = 0(其中xi是常数,vi是向量)有且仅有一个平凡解,那么我 ...
- mysql binaryVInstall
下载mysql 1.下载:在http://dev.mysql.com/downloads/mysql/官网上下载mysql-5.5.28-linux2.6-i686.tar.gz. 2.解压 -lin ...
- Flask 安装 Ubuntu 14.04
学习文档: http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world 中文版学习文档 开源中国版: ...
- ubuntu14.04 安装
summary: a). the way in the internet just a sugestion, I must to do it in my own hands, yes ! just ...
- 通过jdbc取得数据库表结构信息
做制作开发平台时,首要的一点是如何取得数据库表结构信息.一般通用的做法就是通过JDBC中的ResultSetMetaData类来进行操作,当你取得了数据库表结构信息后,比如说表的每个字段名称,字段类型 ...
- SKSpriteNode类
继承自 SKNode:UIResponder:NSObject 符合 NSCoding(SKNode)NSCopying(SKNode)NSObject(NSObject) 框架 /System/L ...
- Android 自定义View (二) 进阶
转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/24300125 继续自定义View之旅,前面已经介绍过一个自定义View的基础的例 ...
- Unix C++(boost) 线程同步和线程组
#include <boost/thread.hpp> #include <iostream> #include <vector> #include <cst ...
- 生成唯一的id(转)
很多朋友都利用md5()来生成唯一的编号,但是md5()有几个缺点:1.无序,导致数据库中排序性能下降.2.太长,需要更多的存储空间.其实PHP中自带一个函数来生成唯一的id,这个函数就是uniqid ...