hdu-1597
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): 3915Problem 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 Input61234510Sample Output112124
首先判断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的更多相关文章
- hdu 1597(矩阵快速幂)
1597: 薛XX后代的IQ Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 228 Solved: 55[Submit][Status][Web Bo ...
- hdu 1597 find the nth digit (数学)
find the nth digit Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- hdu 1597 find the nth digit
find the nth digit Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- HDU题解索引
HDU 1000 A + B Problem I/O HDU 1001 Sum Problem 数学 HDU 1002 A + B Problem II 高精度加法 HDU 1003 Maxsu ...
- HDU——PKU题目分类
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...
- [转] HDU 题目分类
转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...
- HDU ACM 题目分类
模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...
- HDU 2143 Can you find it?(基础二分)
Can you find it? Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/10000 K (Java/Others ...
- 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 ...
- HDU 5643 King's Game 打表
King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...
随机推荐
- Android实战简易教程-第二十三枪(基于Baas的用户注冊和登录模块实现!)
接着上两篇文章.我们基于Bmob提供的API实现用户登录功能.总体看一下代码. 1.注冊页面xml: <RelativeLayout xmlns:android="http://sch ...
- 自动添加QQ
自动添加QQ <meta http-equiv="refresh" content="0; url=tencent://AddContact/?fromId=50& ...
- GreenPlum 安装方法详解
一.安装环境准备 1.磁盘环境准备 磁盘分区典型配置如下: 文件系统 文件格式 大小 / ext3 50GB,Linux系统的根目录,所有的目录都挂在这个目录下面,建议大小为 ...
- OpenCV 入门示例之二:播放 AVI 视频
前言 本文展示一个播放 AVI 视频的程序.( 呵呵是 AVI 视频不是 AV 视频噢! ) 代码示例 // 此头文件包含图像IO函数的声明 #include "highgui.h" ...
- javascript 中 "undefined" 与 "is not defined" 分析
var var1; console.log( typeof var0);//print "undefined",主要看下面对var0单独的输出 console.log( typ ...
- 配置hadoop用户SSH无密码登陆 的2种方式 落脚点是 可以ssh免密进入的主机名写入动作发出主机的 known_hosts,而被无密进入主机的authorized_keys文件 免密登录
cat /proc/versionLinux version 3.10.0-327.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version ...
- Java单元测试(Junit+Mock+代码覆盖率)---------转
Java单元测试(Junit+Mock+代码覆盖率) 原文见此处 单元测试是编写测试代码,用来检测特定的.明确的.细颗粒的功能.单元测试并不一定保证程序功能是正确的,更不保证整体业务是准备的. 单元测 ...
- JVM client模式和Server模式
我们把jdk安装完成后,在命名行输入java -version 不仅可以看到jdk版本相关信息,还会看到类似与 Java HotSpot(TM) 64-Bit Server VM (build 25. ...
- 使用doctrine的内存耗尽解决办法
PHP Fatal error: Allowed memory size of xxx xxx xxx bytes exhausted 无论是插入大量数据或者查询大量数据时,都可能因为数据量太大而出现 ...
- Gym - 100676D Sudoku 基础题
题目链接:https://odzkskevi.qnssl.com/1110bec98ca57b5ce6aec79b210d2849?v=1490453767 题解: 方法1:用STL的set,把每个数 ...