题目

题目

 


 

分析

练习STL

 


 

代码

#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(scanf("%d",&n) && n!=0)
{
queue<int> q;
printf("Discarded cards:");
for(int i=1;i<=n;i++) q.push(i);
while(q.size()!=1)
{
if(q.front()!=1) printf(",");
printf(" %d",q.front()); q.pop();
int x=q.front(); q.pop();
q.push(x);
}
printf("\nRemaining card: %d\n",q.front());
}
return 0;
}

【UVA】10935 Throwing cards away I(STL队列)的更多相关文章

  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,当牌的数目至少还剩下2张时,把第一张牌扔掉,然后把新的一张牌放在牌堆的最底部,问最后剩下的那一张牌是哪一张牌. 模拟队列的操作------- #inclu ...

  3. Uva 10935 Throwing cards away I

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

  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】12100 Printer Queue(STL队列&优先队列)

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

  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. [刷题]算法竞赛入门经典(第2版) 5-3/UVa10935 - Throwing cards away I

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

  8. 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 ...

  9. Throwing cards away I uva1594

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

随机推荐

  1. Linux下的软件的安装

     一.yum相关介绍及命令 [1] 用来管理软件的一个命令.通过该命令完成对软件的下载.卸载等操作. [2] 命令:(必须在yum搭建成功后才能正常运行) yum  clean all      清楚 ...

  2. html dom SetInterVal()

    HTML DOM setInterval() 方法 HTML DOM Window 对象 定义和用法 setInterval() 方法可按照指定的周期(以毫秒计)来调用函数或计算表达式. setInt ...

  3. 监控摄像机常识:宽动态 (WDR)介绍和理解

    安装和使用监控摄像机经常会遇到强光问题. 因为我们不可能灵活选择摄像机的安装位置, 解决或者处理强光是一个无法避免的问题. 不管是由反光材质或者灯源造成此反光, 解决问题的方案来自于摄像机支持的一个特 ...

  4. Kafka 单节点多Kafka Broker集群

    Kafka 单节点多Kafka Broker集群 接前一篇文章,今天搭建一下单节点多Kafka Broker集群环境. 配置与启动服务 由于是在一个节点上启动多个 Kafka Broker实例,所以我 ...

  5. event.preventDefault() 解决按钮多次点击 导致页面变大

    event.preventDefault() 解决按钮多次点击 导致页面变大

  6. vuex(三)actions

    actions:既然mutations只能处理同步函数,我大js全靠‘异步回调’吃饭,怎么能没有异步,于是actions出现了...   actions和mutations的区别     1.Acti ...

  7. 【示例代码】 Tuple<T> Func<T>

    using System; using System.Math; namespace PiWithMonteCarlo { /// <summary> /// Trivial, synch ...

  8. Delphi格式化函数Format、FormatDateTime和FormatFloat详解

    转自:http://outofmemory.cn/code-snippet/7631/Delphi-format-hua-function-Format-FormatDateTime-FormatFl ...

  9. Buy Tickets(线段树单点更新,逆向思维)

    题目大意:有n个的排队,每一个人都有一个val来对应,每一个后来人都会插入当前队伍的某一个位置pos.要求把队伍最后的状态输出. 个人心得:哈哈,用链表写了下,果不其然超时了,后面转念一想要用静态数组 ...

  10. lua resty template && openresty 使用

    1. 安装 luarocks install lua-resty-template 2. 使用   配置模板页面位置     有多种方式:   a.  直接使用root 目录     代码如下:    ...