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. WebSphere下配置HTTP压缩

    WebSphere下配置HTTP压缩 背景 WebSphere本身的安装配置中并不包含HTTP压缩的模块,而是通过新增WebServer来实现的,WebSphere通过Plugin与WebServer ...

  2. Android 其他特效展示

    Android开源项目发现----其他特殊效果篇(持续更新) 发表时间:2014-03-01 15:10:10   来源:本站整理   浏览(160)   Android开源项目发现----其他特殊效 ...

  3. Ubuntu16.04中搭建TFTP 和 NFS 服务器

    Ubuntu 16.04中搭建TFTP服务 1. 安装 $ apt-get install tftp-hpa tftpd-hpa   2. 建立目录 $ mkdir /tftpboot # 这是建立t ...

  4. 记一次网页超时登录的Bug

    前几天,在做全公司的员工测评工作,在一个页面弹出导入页面,并导入所有评价记录,然后关闭掉这个导入页面,最后返回当前页面,返回时刷新当前页面. 在返回的时候,就出现了“页面超时登录”同时返回登录首页的问 ...

  5. 51Nod 1668 非010串

    这是昨天上课ChesterKing dalao讲线代时的例题 当时看到这道题就觉得很水,记录一下后面两位的情况然后讨论一下转移即可 由于之前刚好在做矩阵题,所以常规的矩阵快速幂优化也很简单 好我们开始 ...

  6. 做完小程序项目、老板给我加了5k薪资~

    大家好,我是苏南,今天要给大家分享的是最近公司做的一个小程序项目,过程中的一些好的总结和遇到的坑,希望能给其他攻城狮带来些许便利,更希望能做完之后老板给你加薪- 今天是中秋节的第一天,假日的清晨莫名的 ...

  7. 添加php的memcached扩展模块

    memcached服务直接用yum安装[root@localhost ~]# yum install memcached 然后启动memcache服务,启动多个实例[root@localhost ~] ...

  8. 常用rsync命令操作梳理

    作为一个运维工程师,经常可能会面对几十台.几百台甚至上千台服务器,除了批量操作外,环境同步.数据同步也是必不可少的技能.说到“同步”,不得不提的利器就是rsync.rsync不但可以在本机进行文件同步 ...

  9. 20135337——Linux实践二:模块

    一.编译&生成&测试&删除 1.编写模块代码,查看如下 gedit 1.c(编写) cat 1.c(查看) MODULE_AUTHOR("Z") MODUL ...

  10. SRS用例

    团队项目:超市管理系统     作者:王琨  个人博客地址:http://www.cnblogs.com/wangkun123 一. 用例视图概述 一般的超市商品管理系统,主要由五大模块组成,即商品信 ...