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 ...
随机推荐
- LinkedHashMap使用心得
基本概念:https://www.cnblogs.com/xiaoxi/p/6170590.html 遇到问题: 1.构造方法 public static LinkedHashMap<Strin ...
- 12.1.0.2自适应特性导致SQL性能下降
背景介绍 在升级到12.1.0.2.0数据库版本后,在使用12c中引入的自适应特性默认配置的情况下,可能引起SQL性能的下降. 问题现象升级到12.1.0.2.0后,SQL语句性能可能出现下降. 影响 ...
- [MYSQL笔记0]MYSQL的安装
mysql是一种关系型数据库管理系统.以mysql5.7版本为例,安装过程如下: 首先百度出mysql的官网,进入:(以下是自己安装失败的过程,直接下拉最后看大佬的安装过程吧,就是那个红红的网址) 找 ...
- python基础数据类型之字典的操作
一. 字典的简单介绍字典(dict)是python中唯一的一个映射类型.他是以{ }括起来的键值对组成. 在dict中key是唯一的. 在保存的时候, 根据key来计算出一个内存地址. 然后将key- ...
- java 微信开发 常用工具类(xml传输和解析 json转换对象)
与微信通信常用工具(xml传输和解析) package com.lownsun.wechatOauth.utl; import java.io.IOException; import java.io. ...
- 线程、进程、协程和GIL(三)
上一篇文章介绍了:创建线程的两种方式.Event对象判断线程是否启动.利用信号量控制线程并发. 博客链接:线程.进程.协程和GIL(二) 这一篇来说说线程间通信的那些事儿: 一个线程向另一个线程发送数 ...
- 裸机——LCD
1.先了解显示器们 CRT显示器 原理,使用电子轰击荧光粉实现显示. 特点,主动发光,颜色绚丽,但是大. 等离子显示器(PDP) 原理,在显示屏上排列上千个密封的小低压气体室,通过电流激发使其发出肉眼 ...
- 前端各种mate积累
<!DOCTYPE html> H5标准声明,使用 HTML5 doctype,不区分大小写 <head lang=”en”> 标准的 lang 属性写法 <meta c ...
- spider_main.py
coding=UTF-8 import html_download import html_outputer import html_parser import url_maneger class S ...
- Hive环境搭建及基本操作
伪分布式 一.安装及配置Hive 1.配置HADOOP_HOME和Hive conf 目录hive-env.sh # Set HADOOP_HOME to point to a specific ha ...