题目

题目

 


 

分析

练习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:grep命令详解

    grep grep(global search regular expression(RE) and print out the line,全面搜索正则表达式并把行打印出来)是一种强大的文本搜索工具, ...

  2. 循环中的let和const声明

    一.循环中的let声明 每次循环的时候let声明都会创建一个新变量i,并将其初始化为i的当前值,所以循环内部创建的每个函数都能得到属于他们的i的副本. 最初的: for (var i = 0 ; i ...

  3. flowable FormEngine和FormEngineConfiguration

    FormEngineConfiguration 继承自 AbstractEngineConfiguration. 一.获得实例 FormEngineConfiguration提供了7个公开的静态方法: ...

  4. boost库之udp广播实例

    //UdpLinkServer.h //udp服务 #pragma once #include <boost/asio/ip/tcp.hpp> #include <boost/asi ...

  5. 基于Ubuntu16.04的GeForce GTX 1080驱动安装,遇到的问题及对应的解决方法

    1.在主机上插上GPU之后,查看设备: $ nvidia-smi Tue Dec :: +------------------------------------------------------- ...

  6. vue之element-ui设置全局弹出框

    这样的需求,在主要功能完成后,需要进行交互效果的完善,需要给请求api的时候添加一个加载中的一个弹出框.但是每个页面每个页面过的话,会很费时间和精力,这里我们可以采用element-ui中的服务式弹出 ...

  7. 实战:向GitHub提交代码时触发Jenkins自动构建

    当我们提交代码到GitHub后,可以在Jenkins上执行构建,但是每次都要动手去执行略显麻烦,今天我们就来实战Jenkins的自动构建功能,每次提交代码到GitHub后,Jenkins会进行自动构建 ...

  8. laravel 中禁用掉注册功能

    想让 laravel 做单用户登录,禁止掉注册功能 在 RegisterController 添加以下方法 public function showRegistrationForm() { retur ...

  9. cocos studio pageview看不到indicator指示点

    发现如果在cocos studio里操作给PageView创建页面元素时,即使setIndicatorEnabled为true也看到下方的指示点,必须调用addWidgetToPage或者insert ...

  10. 【备份】 解决acer v5 471g arch关机后自动重启的问题

    Fedora 17 on an Aspire V5-571 -- Reboot on Shutdown13 FEBRUARY 2015Update on 2/13/15: This article w ...