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. Android 解决在初次打开Activity加载布局文件时,ScrollView滚动条不在顶部的问题

    出现这种问题的情况列举:ScrollView中嵌套有(包括自定义)的ListView,GridView时,会出现这种情况 解决办法: 1.在布局加载时让ScrollView上面的那个控件聚焦,具体做法 ...

  2. 7-51单片机ESP8266学习-AT指令(8266TCP服务器,编写自己的C#TCP客户端发信息给单片机控制小灯的亮灭)

    http://www.cnblogs.com/yangfengwu/p/8780182.html 自己都是现做现写,如果想知道最终实现的功能,请看最后 先把源码和资料链接放到这里 链接: https: ...

  3. 十行代码--用python写一个USB病毒 (知乎 DeepWeaver)

    昨天在上厕所的时候突发奇想,当你把usb插进去的时候,能不能自动执行usb上的程序.查了一下,发现只有windows上可以,具体的大家也可以搜索(搜索关键词usb autorun)到.但是,如果我想, ...

  4. Spring Boot 之 Profile 使用

    Spring Boot 之 Profile 使用 一个应用为了在不同的环境下工作,常常会有不同的配置,代码逻辑处理.Spring Boot 对此提供了简便的支持. 关键词: @Profile.spri ...

  5. Python开发技巧

    1 python关闭windows进程 python关闭windows进程的方法,涉及Python调用系统命令操作windows进程的技巧 import os command = 'taskkill ...

  6. Luogu2612 ZJOI2012 波浪 DP

    传送门 花掉了自己用来搞学科的时间做了这道题-- 一道类似的题:Here 考虑拆开绝对值计算贡献.那么我们对于\(1\)到\(N\)的排列,从小到大地将插入它们插入排列中. 假设我们现在计算到了数\( ...

  7. OpenTracing:开放式分布式追踪规范

    前言 想实现一个简单的追踪系统似乎是容易的,需要必要的调用链id,时间戳等:想实现一款易用不侵入代码的追踪系统就很麻烦了,需要接触CLR和IL相关知识:即使你费劲心力做出了那些,如果性能不够好,也没有 ...

  8. [朴智妍][Lullaby]

    歌词来源:http://music.163.com/#/song?id=484056971 作曲 : Bum/Sophiya/김용신 [作曲 : Bum/Sophiya/k/gi-myong-xin] ...

  9. 对象&内置对象& 对象构造 &JSON&__proto__和prototype

    原型是一个对象,其他对象可以通过它实现属性继承 原型链:每个对象都会在其内部初始化一个属性,就是__proto__,当我们访问一个对象的属性 时,如果这个对象内部不存在这个属性,那么他就会去__pro ...

  10. M2阶段事后总结

    设想和目标 1. 我们的软件要解决什么问题?是否定义得很清楚?是否对典型用户和典型场景有清晰的描述?我们的主要任务是将35w+个符合条件的网页,问答,文章放入数据库:爬取功能定义为以下几种:通用型爬取 ...