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 ...
随机推荐
- 表单验证实现React-router跳转
方法一:broserHistory.push handleSubmit(e){ e.preventDefault(); const path = '/demo'; broserHistory.push ...
- 【杂题总汇】Codeforces-67A Partial Teacher
[Codeforces-67A]Partial Teacher 上周刷了一大堆小紫薯的动态规划的题
- SAP 文本框实例
SAP 文本框 简单实例 REPORT ZTEST001. DATA: OK_CODE LIKE SY-UCOMM, SAVE_OK LIKE SY-UCOMM. DATA: REF_EDIT_CTN ...
- mysql 创建用户、授权、修改密码
以下操作都要在mysql所在机器操作 一.创建用户 CREATE USER 'dog'@'localhost' IDENTIFIED BY '123456'; 或 insert into mysql. ...
- zip压缩工具,unzip解压缩工具
zip压缩工具,unzip解压缩工具=================== [root@aminglinux tmp]# yum install -y zip[root@aminglinux tmp] ...
- PHP成随机字符串
生成随机字符串 /** * 随机字符串 * @param int $len * @return string */ function randomStr($len = 32) { $chars = & ...
- TCP/IP协议之http和https协议
一.TCP/IP协议 TCP/IP 是不同的通信协议的大集合. 1.TCP - 传输控制协议 TCP 用于从应用程序到网络的数据传输控制. TCP 负责在数据传送之前将它们分割为 IP 包,然后在它们 ...
- kivy学习一:安装kivy模块
现在是看脸的时代,一个程序没有一个漂亮的UI,就像一个深闺中的美女没人欣赏. 当然作为一个小小.............白,没有那么高的要求,当前要先有脸是不? 首选python自家的模块tkinte ...
- git rebase -i
git rebase -i 作用: 合并提交 示例: 如图所示: 原因: 出现了两个第十一章的提交信息, 其实提交内容是一样的, 但是提交概述不一样. 这就让我很不爽. 我想把两次的概述信息合并为一个 ...
- Android+Handler+Thread 那些事儿
前言,才开始学安卓十几天,不料被线程挡住了前进的步伐,因为之前操作系统课程并没有认真听老师讲课,导致现在理解这些抽象的东西有些小困难.没关系,苦学之路,总会碰到坎坷,这里也给那些迷失在Android之 ...