题意略;

先暴力打表发现规律

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. python QQ邮件发送邮件

    # -*- coding: UTF-8 -*- import smtplib from email.mime.text import MIMEText from email.header import ...

  2. Vsftpd服务 和 TFTP协议

    FTP 文件传输协议 (File Transfer Protocol) FTP是一种在互联网中进行文件传输的协议,基于客户端/服务器模式,默认使用20.21号端口,其中端口20(数据端口)用于进行数据 ...

  3. 11,flask之--WTForms

    WTForms是什么? 相当于django的ModelForm. 在网页中,为了和用户进行信息交互总是不得不出现一些表单.flask设计了WTForm表单库来使flask可以更加简便地管理操作表单数据 ...

  4. RandomAecessFile open failed: EISDIR (Is a directory)

    今天下午搞断点续传,下载文件的时候,弄了一下,我把下载的文件命名为plug.jar.后来老是报错: open failed: EISDIR (Is a directory) 我烦了,两个小时啊,我操. ...

  5. mybatis 关联查询实现一对多

    场景:最近接到一个项目是查询管理人集合  同时每一个管理人还存在多个出资人   要查询一个管理人列表  每个管理人又包含了出资人列表 采用mybatis关联查询实现返回数据. 实现方式: 1 .在实体 ...

  6. Field 'flag' doesn't have a default value错误

    错误代码: java.sql.SQLException: Field 'flag' doesn't have a default value at com.mysql.jdbc.SQLError.cr ...

  7. 设置MySQL允许外网访问 费元星 feiyuanxing.com 站长

    1.修改配置文件sudo vim /etc/mysql/my.cnf把bind-address参数的值改成你的内/外网IP或0.0.0.0,或者直接注释掉这行. 2.登录数据库mysql -u roo ...

  8. Robocopy.exe使用详例

    Robocopy.exe使用详例           Robocopy.exe 是 微软在Windows server 2003 Resource Kit Tools 里面提供的程序来做备份的.Vis ...

  9. 解决NSTimer循环引用

    NSTimer常见用法 @interface XXClass : NSObject - (void)start; - (void)stop; @end @implementation XXClass ...

  10. python3 打印九九乘法口诀表

    for i in range(1, 10): for j in range(1, i+1): # print(f'{i}×{j}={i*j}', end='\t') print('%d×%d=%d' ...