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 ...
随机推荐
- MySQL(九)插入、更新和删除
常用的SQL语句,除了select用于查询,还有insert.update.delete等. 一.insert insert:用来插入(或添加)行到数据库中,常见方式有以下几种: ①插入完整的行: ② ...
- ThreadGroup其实比ExecutorService更好
用java做抓取的时候免不了要用到多线程的了,因为要同时抓取多个网站或一条线程抓取一个网站的话实在太慢,而且有时一条线程抓取同一个网站的话也比较浪费CPU资源.要用到多线程的等方面,也就免不了对线程的 ...
- highcharts中数据列点击事件
Highcharts.chart('container', { xAxis: { categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul ...
- jquery中的选择器:has和:not的用法
这两个选择器可以帮助我们在选择父级和子孙之间关系的dom更从容~ <div><p><span>Hello</span></p></di ...
- Luogu4338 ZJOI2018 历史 LCT、贪心
传送门 题意:在$N$个点的$LCT$中,最开始每条边的虚实不定,给出每一个点的$access$次数,求一种$access$方案使得每条边的虚实变换次数之和最大,需要支持动态增加某个点的$access ...
- Redis命令总结 (转)
Redis命令总结 连接操作相关的命令 quit:关闭连接(connection) auth:简单密码认证 持久化 save:将数据同步保存到磁盘 bgsave:将数据异步保存到磁盘 lastsa ...
- NOIp2014提高组初赛错题简析
总体分析 \(89pts\),粗略来看选择题错的比较多,\(-6pts\).同时又是尿性的填空杀扣了\(5pts\). 不过后面的两大题全对了还是可喜可贺 错题精析 单项选择T8 编译器的主要功能是( ...
- [Oracle]构筑TDE 环境的例子
构筑TDE 环境的例子: 测试环境:12.1.0.2 $ cd $ORACLE_HOME/network/admin$ vim sqlnet.ora $ pwd/u01/app/oracle/prod ...
- 面试2——java基础2
11.MVC设计模型 mvc设计模型是一种使用model-view-controller(模型-视图-控制器)设计创建web应用程序的模式.是一种开发模式,好处是可以将界面和业务逻辑分离. model ...
- python升级后带来的几个小问题
1)python升级带来的yum异常:File "/usr/bin/yum", line 30 原因:这是因为yum采用Python作为命令解释器,这可以从/usr/bin/yum ...