hdu1597
来源:互联网 发布:php编程 编辑:程序博客网 时间:2024/05/03 09:07
假设:
S1 = 1
S2 = 12
S3 = 123
S4 = 1234
.........
S9 = 123456789
S10 = 1234567891
S11 = 12345678912
............
S18 = 123456789123456789
..................
现在我们把所有的串连接起来
S = 1121231234.......123456789123456789112345678912.........
那么你能告诉我在S串中的第N个数字是多少吗?
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)。
61234510
112124
解题思路:
这道题真的爆炸,很简单很简单的暴力。。。开始预处理数组,但是用的是i*(i+1),说是会爆int,但是我开的是long long,还一直wa,当时心态真的爆炸,不知道哪里出问题,就是一直wa,然后基本上就放弃了后面的题目。。。根本不想看。。。
代码:
#include<iostream>using namespace std;int main(){ int t; cin>>t; while(t--) { int n; cin>>n; int a = 1; while(n>a) { n-=a; a++; } n%=9; if(n==0) { cout<<"9"<<endl; continue; } cout<<n<<endl; }}
阅读全文
0 0
- HDU1597
- hdu1597
- hdu1597
- HDU1597
- hdu1597
- hdu1597(规律)
- hdu1597(二分查找)
- HDU1597二分查找
- hdu1597 简单二分
- HDU1597【二分瞎搞】
- HDU1597(二分)
- hdu1597的两种解法
- HDU1597 find the nth digit
- HDU1597 find the nth digit
- hdu1597 find the nth digit(规律)
- HDU1597 find the nth digit【模拟】
- hdu1597.cuo le n ci.为什么还要和n比较
- HDU1597 - find the nth digit (找规律)
- 使用PHPExcel导出Excel表
- 一个封装好的Slf4jLogUtil工具类(下)
- maven配置setting.xml报Could not read settings.xml
- 多线程管理
- 【ARM】Exynos 4412 IIC(I2C)总线详解
- hdu1597
- TP控制器post带参传递
- MD5在线加密.
- Js中的对象、构造函数、原型、原型链及继承
- VS2015运行程序时拒绝访问
- Linux安装Git(1.7版本)客户端
- SEO(搜索引擎优化)浅谈普及一下搜索引擎的核心算法
- hive-01-hive集群安装,连接mysql
- strsafe与oralib