find the nth digit

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 7403    Accepted Submission(s): 2120

Problem Description
假设:
S1 = 1
S2 = 12
S3 = 123
S4 = 1234
.........
S9 = 123456789
S10 = 1234567891
S11 = 12345678912
............
S18 = 123456789123456789
..................
现在我们把所有的串连接起来
S = 1121231234.......123456789123456789112345678912.........
那么你能告诉我在S串中的第N个数字是多少吗?
 
Input
输入首先是一个数字K,代表有K次询问。
接下来的K行每行有一个整数N(1 <= N < 2^31)。
 
Output
对于每个N,输出S中第N个对应的数字.
 
Sample Input
6
1
2
3
4
5
10
 
Sample Output
1
1
2
1
2
4
 
Author
8600
 
Source
 
Recommend
8600   |   We have carefully selected several similar problems for you:  1595 1016 1599 1677 1598 
 
 //453MS    256K    301 B    C++
/* 题意:
中文,找规律下第n个数是什么 数学规律:
其实早该看出该规律了..不过暴力的话应该会TLE才对...
用二分法找那个数应该不会TLE才对....
后来都试过了..都会TLE,加个中间变量又不会TLE...
略感无解... */
#include<stdio.h>
int main(void)
{
int t,n;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
int a=;
int m=n;
while(m>a){
m-=a;
a++;
}
printf("%d\n",m%==?:m%);
}
return ;
}

hdu 1597 find the nth digit (数学)的更多相关文章

  1. hdu 1597 find the nth digit

    find the nth digit Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  2. 【HDOJ】1597 find the nth digit

    二分. #include <stdio.h> #include <math.h> int main() { int case_n; double n, tmp, l, r; i ...

  3. find the nth digit(二分查找)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1597 find the nth digit Time Limit: 1000/1000 MS (Jav ...

  4. (lower_bound)find the nth digit hdu1597

    find the nth digit Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  5. [LeetCode] Nth Digit 第N位

    Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... Note: n i ...

  6. Leetcode: Nth Digit

    Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... Note: n i ...

  7. Nth Digit | leetcode

    Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... Note: n i ...

  8. [Swift]LeetCode400. 第N个数字 | Nth Digit

    Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... Note:n is ...

  9. C++版 - Leetcode 400. Nth Digit解题报告

    leetcode 400. Nth Digit 在线提交网址: https://leetcode.com/problems/nth-digit/ Total Accepted: 4356 Total ...

随机推荐

  1. Laravel Nginx 除 `/` 外所有路由 404

    解决方法 在nginx配置添加以下设置: location / { try_files $uri $uri/ /index.php?$query_string; } 详见Laravel官方文档:htt ...

  2. yii2 的登录注册 轮子

    //利用到了yii2 框架之中的验证规则 进行判定而已 也不是很高深的东西  但是 使用框架自身的轮子 会有安全性能的隐患 1注册reg controller 中 我都以admin 为例子 publi ...

  3. Sublime package control错误:There are no packages available for installation

    查了很多资料都没有解决. 改host---无效 复制一个文件的什么的,我看到版本比我的旧,就没有用 终于最后一个解决了.最终解决方案 解决: 更新下Package Control就好了: prefer ...

  4. IAR 编译时找不到头文件的解决方法

    Fatal Error[Pe1696]: cannot open source file "x.h" 那是因为头文件路径没有找对 到报错的.c源文件 选中右键 选择options ...

  5. strak组件(6):列表定制列应用和引入静态文件

    效果图: 新增函数 def get_choice_text(title, field) 闭包函数,显示choice字段 def inner(self, obj=None, is_header=None ...

  6. C语言进阶——浮点数的秘密03

    浮点数在内存中的储存方式为:符号位 指数位 尾数 float和double类型的数据在计算机内部的表实方法是一样的,但是由于所占的存贮空间的不同,其分别能表示的数值范围和精度不同. 类型 f符号位 指 ...

  7. https://www.cnblogs.com/gaoxiang12/p/3695962.html

    https://www.cnblogs.com/gaoxiang12/p/3695962.html

  8. 笔记-redis安装

    笔记-redis安装配置 1.      redis安装配置 1.1.    windows环境安装 win8已有redis 查看版本:redis-server –version 想更新到5.0.0, ...

  9. 邮件系统之Postfix与Dovecot

    电子邮件系统 电子邮件系统基于邮件协议来完成电子邮件的传输,常见的邮件协议有: 简单邮件传输协议(Simple Mail Transfer Protocol,SMTP):用于发送和中转发出的电子邮件, ...

  10. [bzoj2932][POI1999]树的染色问题

    被百度搜到的题解(论文?)坑了. 写的那玩意好像石乐志... Description 一棵二叉树采用以下规则描述: 1.如果一个节点度数为0,则仅用一个元素“0”来描述它. 2.如果一个节点度数为1, ...