POJ1019-Number Sequence-数数。。
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-数数。。的更多相关文章
- POJ1019——Number Sequence(大数处理)
Number Sequence DescriptionA single positive integer i is given. Write a program to find the digit l ...
- POJ1019 Number Sequence
Number Sequence Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 36256 Accepted: 10461 ...
- [LeetCode] Super Ugly Number 超级丑陋数
Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...
- [LeetCode] 264. Ugly Number II 丑陋数 II
Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors ...
- [LeetCode] 313. Super Ugly Number 超级丑陋数
Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...
- hihoCoder 1432 : JiLi Number(吉利数)
hihoCoder #1432 : JiLi Number(吉利数) 时间限制:1000ms 单点时限:1000ms 内存限制:256MB Description - 题目描述 Driver Ji l ...
- 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 ...
- [LeetCode] 137. Single Number II 单独数 II
Given a non-empty array of integers, every element appears three times except for one, which appears ...
- [LeetCode] 247. Strobogrammatic Number II 对称数II
A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside ...
- [LeetCode] 248. Strobogrammatic Number III 对称数III
A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside ...
随机推荐
- Luogu3613 睡觉困难综合征/BZOJ4811 Ynoi2017 由乃的OJ 树链剖分、贪心
传送门 题意:给出一个$N$个点的树,树上每个点有一个位运算符号和一个数值.需要支持以下操作:修改一个点的位运算符号和数值,或者给出两个点$x,y$并给出一个上界$a$,可以选取一个$[0,a]$内的 ...
- 个人博客地址: furur.xyz
趁着Hexo的热度,最近就买了域名,在GitHub Pages上搭了个人博客.也不是说博客园不好吧,毕竟在博客园三年多,也学到了不少东西,唯一要吐槽的,估计也就是后台管理不方便,markdown无即时 ...
- 仓储层接口IBaseRepository解析
//代码调用由业务层调用,调用方式详见源代码的业务层,升级直接替换TT模板即可,无需覆盖系统using System; using System.Collections.Generic; using ...
- Linux df du 命令
df 命令 检查磁盘空间占用情况(并不能查看某个目录占用的磁盘大小). 命令格式:df [option] -h 以容易理解的格式(给人看的格式)输出文件系统分区使用情况,例如 10kB.10MB.10 ...
- 我的AutoHotkey脚本
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. ; #Warn ; En ...
- Kafka(分布式发布-订阅消息系统)工作流程说明
Kafka系统架构Apache Kafka是分布式发布-订阅消息系统.它最初由LinkedIn公司开发,之后成为Apache项目的一部分.Kafka是一种快速.可扩展的.设计内在就是分布式的,分区的和 ...
- SE Springer小组之《Spring音乐播放器》需求分析说明书二
2.1 目标 Spring音乐播放器软件为课程<软件工程>所开发的课程作业,主要意图是为访问计算机中的mp3格式的音频文件,并使其能够完成访问,读取,添加,保存,播放,切换音频文件等功能. ...
- 关于HashMap和Hashtable的区别
Hashtable的应用非常广泛,HashMap是新框架中用来代替Hashtable的类,也就是说建议使用HashMap,不要使用Hashtable.可能你觉得Hashtable很好用,为什么不用呢? ...
- "一个程序员的生命周期"读后感
这篇文章中作者叙述了自己和大多数大学生或许都会面对的问题,即是会走过挺多的歪路,面临很多的困难和压力,但是作者却从未放弃自己真正追求的东西.对于一个过来人的经验之谈,我们应该吸取经验,在大学好好去奋斗 ...
- Daily Scrum- 12/28
Meeting Minutes 讨论alpha 的feed back; 决定添加按钮向下的动作,作为feature; 完成了界面的微调,开始使用alpha.1进行feed back的收集 Burndo ...