1

12

123

1234

把数按照这样的形式拍成一排,给一个序号求出那个序号对应的数。

当出现两位数。三位数时,要麻烦的处理一下。

#include <cstdio>
#include <algorithm>
#include <cmath> using namespace std; int T,N,ans; int getbit(int x)
{
int rtn = ;
while(x)
{
x/=;
rtn++;
}
return rtn;
} int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%d",&N);
int cur = ,cnt = ;;
while(true)
{
if(N <= cur) break;
N -= cur;
cnt++;
cur += getbit(cnt);
}
//printf("N=%d cur=%d cnt=%d\n",N,cur,cnt);
cur = ,cnt = ;
while(true)
{
if(N <= cur) break;
N -= cur;
cnt++;
cur = getbit(cnt);
}
//printf("N=%d cur=%d cnt=%d\n",N,cur,cnt); if(cur == N) ans = cnt%;
else ans = (int)(cnt/pow(,cur-N)) % ;
printf("%d\n",ans);
}
}

POJ1019-Number Sequence-数数。。的更多相关文章

  1. POJ1019——Number Sequence(大数处理)

    Number Sequence DescriptionA single positive integer i is given. Write a program to find the digit l ...

  2. POJ1019 Number Sequence

    Number Sequence Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 36256   Accepted: 10461 ...

  3. [LeetCode] Super Ugly Number 超级丑陋数

    Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...

  4. [LeetCode] 264. Ugly Number II 丑陋数 II

    Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors ...

  5. [LeetCode] 313. Super Ugly Number 超级丑陋数

    Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...

  6. hihoCoder 1432 : JiLi Number(吉利数)

    hihoCoder #1432 : JiLi Number(吉利数) 时间限制:1000ms 单点时限:1000ms 内存限制:256MB Description - 题目描述 Driver Ji l ...

  7. 1. CountDiv 数数有几个 Compute number of integers divisible by k in range [a..b].

    package com.code; public class Test05_1 { public static int solution(int A, int B, int K) { // handl ...

  8. [LeetCode] 137. Single Number II 单独数 II

    Given a non-empty array of integers, every element appears three times except for one, which appears ...

  9. [LeetCode] 247. Strobogrammatic Number II 对称数II

    A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside ...

  10. [LeetCode] 248. Strobogrammatic Number III 对称数III

    A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside ...

随机推荐

  1. VS2017上执行VS2013项目错误MSB802之解决方案

    进行想把我编写的数字图像处理软件MagicHouse更新到最新的VS2017开发环境下,原来的开发环境是VS2013.但是用VS2017打开项目并编译时,系统报错误MSB802,如下图所示. 其实Vi ...

  2. odooERP系统(框架)总结

    1:Odoo 是一个现代化的商业应用套件,使用 AGPL 许可证,并具有客户关系管理(CRM),人力资源,销售,采购,会计,制造,仓库管理,项目管理,以及众多社区模块. 2:它是基于一个模块化,可扩展 ...

  3. odoo系统之产品表

    # 输入产品带出它默认的包装方式\单位\品名\规格 def get_product_unit(self, cr, uid,ids,product_id,pcust_order_no,pdate_pla ...

  4. 解决 HttpWebResponse.GetResponse()一直提示超时

    原文首发: http://anforen.com/wp/2018/04/httpwebresponsegetresponse/ HttpWebResponse response = (HttpWebR ...

  5. 一个有趣的问题——HTTP是“超文本传输协议”还是“超文本转移协议”

    最近在看<HTTP图解>这本书,书中提到了对国内对HTTP协议名称的翻译问题,并且给出了一些网友讨论的原稿链接,我看了一下觉得挺有意思的,另外我本人也觉得翻译对于理解协议本身非常重要,就整 ...

  6. Dubbo(四) Dubbo-Admin项目 Dubbo管理台

    前言 在dubbo项目中,有注册中心,消费者,提供者就足以构成一个完整的项目了.但是仅仅有这三个角色,很难对整个项目状态有直观的了解,以及对项目操作. 因此早有前辈对此原因作出了贡献——一个通用的du ...

  7. 001_IntelliJ IDEA详细安装步骤

    安装IntelliJ IDEA 一.安装JDK 1 下载最新的jdk,这里下的是jdk-8u66 2 将jdk安装到默认的路径C:\Program Files\Java目录下 二.安装IntelliJ ...

  8. 编写脚本自动部署反向代理、web、nfs

    服务器端 #!/bin/bash function nginx_install(){ if [[ -f /usr/sbin/nginx ]]; then echo 'Nginx has been in ...

  9. tomcat相关配置技巧梳理 (修改站点目录、多项目部署、限制ip访问、大文件上传超时等)

    tomcat常用架构:1)nginx+tomcat:即前端放一台nginx,然后通过nginx反向代理到tomcat端口(可参考:分享一例测试环境下nginx+tomcat的视频业务部署记录)2)to ...

  10. 对PS的评价

    Photoshop(简称:PS)是电脑上的图像处理软件:对于广大Photoshop爱好者而言,PS亦用来形容通过该类图形处理软件处理过的图片,即非原始.非未处理的图片:多数人对于这软件的了解仅限于“一 ...