【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

用STL的queue写

【代码】

#include <bits/stdc++.h>
using namespace std; queue <int> dl;
vector <int> v;
int n; int main()
{
//freopen("F:\\rush.txt", "r", stdin);
while (~scanf("%d", &n) && n)
{
v.clear();
while (!dl.empty()) dl.pop(); for (int i = 1; i <= n; i++) dl.push(i);
for (int i = 1; i <= n - 1; i++)
{
v.push_back(dl.front());
dl.pop();
dl.push(dl.front());
dl.pop();
}
printf("Discarded cards:");
for (int i = 0; i < n - 1; i++)
{
printf(" %d%c", v[i], i == n - 2 ? '\n' : ',');
}
if (n == 1) puts("");
printf("Remaining card: %d\n", dl.front());
}
return 0;
}

【习题5-3 UVA-10935】Throwing cards away I的更多相关文章

  1. UVa 10935 - Throwing cards away I (队列问题)

    原题 Throwing cards away I   Given is an ordered deck of n cards numbered 1 to n with card 1 at the to ...

  2. Uva 10935 Throwing cards away I

    题目意思:有N张牌,标号为1~N,且牌以叠好,从上到小就是标号1-N的牌,只要牌堆数量大于等于2的时候,就采取如下操作:将最上面的牌扔掉(即离开牌堆).刚才那张牌离开后,再将新的最上面的牌放置于牌堆最 ...

  3. UVa 10935 Throwing cards away I【队列】

    题意:给出 n张牌,从上往下编号依次为1到n,当牌的数目至少还剩下2张时,把第一张牌扔掉,然后把新的一张牌放在牌堆的最底部,问最后剩下的那一张牌是哪一张牌. 模拟队列的操作------- #inclu ...

  4. uva 10935 throwing cards away <queue>

    Given is an ordered deck of    n    cards numbered 1 to    n    with card 1 at the top and card    n ...

  5. 【UVA】10935 Throwing cards away I(STL队列)

    题目 题目     分析 练习STL     代码 #include <bits/stdc++.h> using namespace std; int main() { int n; wh ...

  6. UVA 10940 Throwing cards away II

    题意略: 先暴力打表发现规律 N=1 ans=1N=2 ans=2N=3 ans=2N=4 ans=4N=5 ans=2N=6 ans=4N=7 ans=6N=8 ans=8N=9 ans=2N=10 ...

  7. Throwing cards away I

    Throwing cards away I   Given is an ordered deck of n cards numbered 1 to n with card 1 at the top a ...

  8. UVa---------10935(Throwing cards away I)

    题目: Problem B: Throwing cards away I Given is an ordered deck of n cards numbered 1 to n with card 1 ...

  9. [刷题]算法竞赛入门经典(第2版) 5-3/UVa10935 - Throwing cards away I

    书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,0 ms) //UVa10935 - Throwing cards away I #incl ...

  10. POJ 1511 Invitation Cards / UVA 721 Invitation Cards / SPOJ Invitation / UVAlive Invitation Cards / SCU 1132 Invitation Cards / ZOJ 2008 Invitation Cards / HDU 1535 (图论,最短路径)

    POJ 1511 Invitation Cards / UVA 721 Invitation Cards / SPOJ Invitation / UVAlive Invitation Cards / ...

随机推荐

  1. ASPNET 页面编码

    转自:http://www.cnblogs.com/libingql/archive/2009/04/11/1433771.html 设置ASPNET页面编码格式 1.Web.Config设置 < ...

  2. amaze ui响应式辅助

    amaze ui响应式辅助 响应式辅助 就是不同的显示屏幕,或者手机的横竖屏,你可以控制栏目的显影,还是挺有帮助的 视口大小 .am-[show|hide]-[sm|md|lg][-up|-down| ...

  3. 关于jquery点击之后,标签的hover失效这个问题

    做一个点击切换的效果,加在a标签上,jquery的click加上css中的hover 点击之后,css的hover效果就没有了,后来知道是click的权值比外联的css大 当点击之后,css代码就被覆 ...

  4. Kinect 开发 —— ColorBasic

    创建一个Kincet项目通常需要: 1. 创建一个VS项目,一般为了展示通常创建一个wpf项目. 2. 添加Microsoft.Kinect.dll引用,如果是早期版本的SDK,这个名称可能不同. 3 ...

  5. POJ 1474 Video Surveillance 半平面交/多边形核是否存在

    http://poj.org/problem?id=1474 解法同POJ 1279 A一送一 缺点是还是O(n^2) ...nlogn的过几天补上... /********************* ...

  6. python 中文文档地址总结

    sqlalchemy: https://www.imooc.com/article/details/id/22343

  7. Lusac定理

    转载大佬的模版:http://www.cnblogs.com/vongang/archive/2012/12/02/2798138.html

  8. Gym - 100548C The Problem Needs 3D Arrays

    Problem C.   The Problem Needs 3D Arrays Time Limit: 6000MS Memory Limit: 262144KB 64bit IO Format: ...

  9. Oracle与MySQL的转化差异

    1.nvl函数.        Oracle 中 : nvl (join_count , 0)        MySQL中:if(join_count is null,'0',join_count)  ...

  10. highcharts 阶梯图表并填充颜色(自己觉得:直角折线图表)

    例如以下:普通阶梯图 $(function () { $('#container').highcharts({         title: {         text: '普通阶梯图'       ...