hdu 1597 find the nth digit (数学)
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
S1 = 1
S2 = 12
S3 = 123
S4 = 1234
.........
S9 = 123456789
S10 = 1234567891
S11 = 12345678912
............
S18 = 123456789123456789
..................
现在我们把所有的串连接起来
S = 1121231234.......123456789123456789112345678912.........
那么你能告诉我在S串中的第N个数字是多少吗?
接下来的K行每行有一个整数N(1 <= N < 2^31)。
1
2
3
4
5
10
1
2
1
2
4
//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 (数学)的更多相关文章
- hdu 1597 find the nth digit
find the nth digit Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- 【HDOJ】1597 find the nth digit
二分. #include <stdio.h> #include <math.h> int main() { int case_n; double n, tmp, l, r; i ...
- find the nth digit(二分查找)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1597 find the nth digit Time Limit: 1000/1000 MS (Jav ...
- (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 ...
- [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 ...
- 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 ...
- 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 ...
- [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 ...
- C++版 - Leetcode 400. Nth Digit解题报告
leetcode 400. Nth Digit 在线提交网址: https://leetcode.com/problems/nth-digit/ Total Accepted: 4356 Total ...
随机推荐
- ssh框架复习
1.Hibernate中实体类的创建规则是什么? 2.hibernate中实体类的三种状态? 三种状态: 1. new 出来一个新对象 TakeTime takeTime = new TakeTime ...
- 使用Git操作码云
一.安装并配置 .安装git 下载地址: 官方网站:https://git-for-windows.github.io/ 国内镜像:https://pan.baidu.com/s/1kU5OCOB#l ...
- 如何设置 html 中 select 标签不可编辑、只读
转载自: https://blog.csdn.net/hjm4702192/article/details/33729767 1. <select style="width:195px ...
- (转)想从事游戏开发,1 年内能精通 C++ 吗,还需要学习什么?
本人大约从20多年前开始学习及使用C++,但仍未达到我认为「精通」的阶段,甚至对于C++11的各种新特性也未掌握.然而因为我是在读书时自学C++的,也是游戏程序员(原问题中提到题主想从事游戏开发),觉 ...
- php 文件操作和文件上传
文件操作 http://www.w3school.com.cn/php/php_file.asp http://www.w3school.com.cn/php/php_file_open.asp ht ...
- Codeforces Round #458C DP
C. Travelling Salesman and Special Numbers time limit per test 1 second memory limit per test 256 me ...
- 寻找物体的凸包 opencv
凸包的含义: 在二维平面上给定点集,凸包就是将最外层的点连接起来构成的凸多边形.并且这个凸多边形能包含点集中所有的点.OPENCV中: convexHull函数用于寻找图像点集中的凸包.它有六个输入参 ...
- salt demo 环境
demo 环境 安装 virtualBox和vagrant 安装工具包:virtualBox, vagrant 下载 https://github.com/UtahDave/salt-vagrant- ...
- [Python3.x]python3.5实现socket通讯(TCP)
TCP连接: tcp是面向连接的一个协议,意味着,客户端和服务器开发发送数据之前,需要先握手创建一个TCP连接.TCP连接的一端与客户端套接字相互联系,另一端与服务器套接字相联系.当创建该TCP连接的 ...
- tools.jar seem to ....
android stadio 运行不起来,可以在java_home原来的路径下加一个\, 然后就可以运行起来了.