find the nth digit

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

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

首先判断n在哪一层,再把n对9取模找到对应的数字。

AC代码:

 #include<bits/stdc++.h>
using namespace std; int main(){
int a,n,t;
cin>>t;
while(t--){
cin>>n;
int a=;
while(n>a){
n-=a;
a++;
}
n%=;
if(n==)
n=;
cout<<n<<endl;
}
return ;
}

hdu-1597的更多相关文章

  1. hdu 1597(矩阵快速幂)

    1597: 薛XX后代的IQ Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 228  Solved: 55[Submit][Status][Web Bo ...

  2. hdu 1597 find the nth digit (数学)

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

  3. hdu 1597 find the nth digit

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

  4. HDU题解索引

    HDU 1000 A + B Problem  I/O HDU 1001 Sum Problem  数学 HDU 1002 A + B Problem II  高精度加法 HDU 1003 Maxsu ...

  5. HDU——PKU题目分类

    HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...

  6. [转] HDU 题目分类

    转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...

  7. HDU ACM 题目分类

    模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...

  8. HDU 2143 Can you find it?(基础二分)

    Can you find it? Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/10000 K (Java/Others ...

  9. HDU 1599 find the mincost route(floyd求最小环 无向图)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1599 find the mincost route Time Limit: 1000/2000 MS ...

  10. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

随机推荐

  1. tensor搭建--windows 10 64bit下安装Tensorflow+Keras+VS2015+CUDA8.0 GPU加速

    windows 10 64bit下安装Tensorflow+Keras+VS2015+CUDA8.0 GPU加速 原文见于:http://www.jianshu.com/p/c245d46d43f0 ...

  2. eclipse代码注释模版

    设置注释模板的入口: Window->Preference->Java->Code Style->Code Template 然后展开Comments节点就是所有需设置注释的元 ...

  3. iOS开发 - UIViewController控制器管理

    创建一个控制器 控制器常见的创建方式有下面几种 //通过storyboard创建 //直接创建 ViewController *vc = [[ViewController alloc] init]; ...

  4. 使用openssl 生成RSA pem格式的公钥私钥

    1.生存私钥 openssl genrsa -des3 -out private_key.pem 1024 2.生成公钥 openssl rsa -in private_key.pem -pubout ...

  5. VC ++6.0英文版常用菜单使用参考【转载整理】

    (1)File菜单 New:打开“new”对话框,以便创建新的文件.工程或工作区. Close Workspace:关闭与工作区相关的所有窗口. Exit:退出VC6环境,将提示保存窗口内容等. (2 ...

  6. 九度OJ 1113:二叉树 (完全二叉树)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:5079 解决:1499 题目描述: 如上所示,由正整数1,2,3--组成了一颗特殊二叉树.我们已知这个二叉树的最后一个结点是n.现在的问题是 ...

  7. CSS3学习笔记(1)—淡入的文字

    今天有空把前几天学的东西发一下,都是一些简单的东西,但是千里之行始于足下,我虽然走的慢,但是未停下前进的脚步, 下来看下我做的“淡入的文字”最终动态效果: 上面这个动画效果制作的过程是: (1)先自定 ...

  8. 转回java,项目遇到的环境相关问题记录

    fastjson解析报错,兼容java8的time包:需要升级fastjson版本到1.2.9 https://www.oschina.net/question/129411_142776     j ...

  9. js获取浏览器宽高、网页宽高、屏幕宽高、鼠标位置等(带图片说明)

    网页可见区域宽: document.body.clientWidth;网页可见区域高: document.body.clientHeight;(点击查看大图) 网页可见区域宽: document.bo ...

  10. nyoj 1030 hihocoder 1338

    题目链接1: 点这里打开. 题目链接2:   点击打开链接 思路:dp,dp[i][j] 表示某个人在区间 i,j上的得分. sum数组表示前 n 项和, num 数组用来存输入的数字. 因为取数字是 ...