HDOJ 1597 find the nth digit
来源:互联网 发布:linux gcc 编译 编辑:程序博客网 时间:2024/06/16 22:27
find the nth digit
Problem Description
假设:
S1 = 1
S2 = 12
S3 = 123
S4 = 1234
.........
S9 = 123456789
S10 = 1234567891
S11 = 12345678912
............
S18 = 123456789123456789
..................
现在我们把所有的串连接起来
S = 1121231234.......123456789123456789112345678912.........
那么你能告诉我在S串中的第N个数字是多少吗?
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)。
接下来的K行每行有一个整数N(1 <= N < 2^31)。
Output
对于每个N,输出S中第N个对应的数字.
Sample Input
61234510
Sample Output
112124
代码如下:
普通解法
#include <cstdio>#include <cmath>typedef long long ll;int main(){ int n,k; int i,j; scanf("%d",&k); while(k--){ scanf("%d",&n); i = 1; while(n > i){ n -= i; i++; } n = (n - 1) % 9 + 1; printf("%d\n",n); } return 0;}
0 0
- HDOJ-1597find the nth digit
- hdoj-1597-find the nth digit
- HDOJ 1597 find the nth digit
- hdoj 1597 find the nth digit 大水题!!
- HDOJ 题目1597 find the nth digit(数学)
- find the nth digit
- find the nth digit
- find the nth digit
- find the nth digit
- find the nth digit
- find the nth digit
- find the nth digit
- find the nth digit
- find the nth digit
- hdu Problem - 1597 find the nth digit
- HDU 1597 find the nth digit
- 1597—find the nth digit
- hdu 1597 find the nth digit
- POJ-----3258二分
- iOS杂记——category分类、extension扩展、protocol协议
- Java引用类型
- Java Mysql Hive操作
- [Cloud Computing]Mechanisms: Virtual Firewall
- HDOJ 1597 find the nth digit
- 研究完Linux C的文件IO和文件系统,接着需要看进程和信号控制
- SDUT3325顺序表应用2:多余元素删除之建表算法
- TextView更多的属性
- 用R语言进行回归分析
- LDD3 字符设备驱动
- 如何部署软件 - 让你团队的部署像地狱一样无聊且毫无压力
- Android笔记--两种双击退出程序的方法
- Android相对布局RelativeLayout,Intent用法,Intent传值(对象),Intent.action大全