题意略;

先暴力打表发现规律

N=1 ans=1
N=2 ans=2
N=3 ans=2
N=4 ans=4
N=5 ans=2
N=6 ans=4
N=7 ans=6
N=8 ans=8
N=9 ans=2
N=10 ans=4
N=11 ans=6
N=12 ans=8
N=13 ans=10
N=14 ans=12
N=15 ans=14
N=16 ans=16
N=17 ans=2
N=18 ans=4
N=19 ans=6
N=20 ans=8
N=21 ans=10
N=22 ans=12
N=23 ans=14
N=24 ans=16
N=25 ans=18
N=26 ans=20
N=27 ans=22
N=28 ans=24
N=29 ans=26
N=30 ans=28
N=31 ans=30
N=32 ans=32

这规律很明显了就略了。。直接上代码了

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <stack>
#include <queue>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define PI 3.1415926535897932626
using namespace std;
int gcd(int a, int b) {return a % b == ? b : gcd(b, a % b);}
#define MAXN 500003
vector<int>tab[];
int num[];
int N;
void init()
{
for (int i=;i<;i++) tab[i].clear();
tab[].push_back();
for (int i=;i<;i++)
{
int limit=<<i;
int cas=;
while (cas<=limit)
{
tab[i].push_back(cas);
cas+=;
}
}
num[]=;
for (int i=;i<;i++) num[i]=num[i-]+tab[i].size();
}
int main()
{
init();
while (scanf("%d",&N)!=EOF)
{
if (N==) break;
if (N==) {puts("");continue;}
int cas=,i;
for ( i=;i<;i++)
{
cas+=tab[i].size();
if (cas>=N) break;
}
int tmp=N-num[i-];
printf("%d\n",tab[i][tmp-]);
}
return ;
}

UVA 10940 Throwing cards away II的更多相关文章

  1. UVA10940 - Throwing cards away II(找到规律)

    UVA10940 - Throwing cards away II(找规律) 题目链接 题目大意:桌上有n张牌,依照1-n的顺序从上到下,每次进行将第一张牌丢掉,然后把第二张放到这叠牌的最后.重复进行 ...

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

  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

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

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

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

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

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

  9. 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. 007---Django的视图层

    视图函数 一个视图函数,简称视图,是一个简单的python函数.它接收web请求并且返回web响应. 1.一张网页的HTML内容 2.一个重定向 3.一个404错误 4.一个xml文档 5.一个字符串 ...

  2. POJ:3684-Physics Experiment(弹性碰撞)

    Physics Experiment Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3392 Accepted: 1177 Sp ...

  3. 笔记-scrapy-Request/Response

    笔记-scrapy-Request/Response 1.     简介 Scrapy使用Request和Response来爬取网站. 2.     request class scrapy.http ...

  4. python基础之装饰器扩展和迭代器

    wraps模块 让原函数保留原来的说明信息 import time import random from functools import wraps def auth(func): '''auth ...

  5. Android 自定义圆形图片 CircleImageView

    1.效果预览 1.1.布局中写自定义圆形图片的路径即可 1.2.然后看一看图片效果 1.3.原图是这样的 @mipmap/ic_launcher 2.使用过程 2.1.CircleImageView源 ...

  6. 多路复用IO模板

    服务端 from socket import * import select server = socket(AF_INET, SOCK_STREAM) server.bind(('127.0.0.1 ...

  7. Maven学习 (六) 搭建多模块企业级项目

    首先,前面几次学习已经学会了安装maven,如何创建maven项目等,最近的学习,终于有点进展了,搭建一下企业级多模块项目. 好了,废话不多说,具体如下: 首先新建一个maven项目,pom.xml的 ...

  8. Visual Studio使用技巧笔记(引用程序集自动复制dll到引用项目目录)

    copy /y $(TargetPath) $(SolutionDir)\[您项目引用dll文件的目录]\$(TargetFileName) 例如:copy /y $(TargetPath) $(So ...

  9. python学习总结---面向对象1

    面向对象 - 与面向过程对比 - 面向过程:数学逻辑的映射,学会做个好员工. - 面向对象:生活逻辑的映射,学会做个好领导. - 生活实例 - 类: 人 手机 电脑 - 对象: 习大大.普京 二狗的i ...

  10. springboot07 mysql02

    多表关系 一.表关系介绍 1. 表之间为什么要有关系 一般来讲,通常都是一张表某一类型数据,比如学生数据存储在学生表,教师数据存储在教师表,学科数据存储在学科表.但是有时候我们需要表示一个学生属于哪一 ...