HDU1597
来源:互联网 发布:skycc营销软件系统 编辑:程序博客网 时间:2024/05/16 06:09
题目大意:就是拼串,注意到第n个串,就有多少长度的数,每9个数一个循环。求最后的串中第n个数
思路:超级水题,但是有一点很坑爹,2^31次方,int类型过不去!WA了5次,还以为是精度问题。
先用等差数列的求和公式求出(解一元二次方程)n在第几串字符串中,再求出在该串中排第几,就可以通过模9来解决问题
program:
#include<iostream>
#include<math.h>
#include<string.h>
#include<stdio.h>
using namespace std;
int main()
{
__int64 test,n;
cin>>test;
string str="912345678";
while(test--)
{
cin>>n;
__int64 tmp=(__int64)ceil((sqrt((1+8*n)*1.0)-1.0)/2);
__int64 tmp2=(tmp*tmp+tmp)/2;
__int64 last=tmp-(tmp2-n);
cout<<str[last%9]<<endl;
}
//system("pause");
return 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 (找规律)
- 创建Oracle用户和表空间
- Game
- hadoop作业调优参数整理及原理
- How to use Log4net in your project
- 多媒体的一些基本概念
- HDU1597
- Hadoop-CDH4的部署包的文件结构
- 巧用好官方API学好EXTJS
- 价格战草草收场 电商巨头空赚知名度赔了美誉度
- 第二次量产成功:KingSton DT 101 G2 8G的量产经历
- Java split
- IT项目管理工具
- 一起读nodejs(三)----模块(Modules)
- Editlog的接口规范设计文档(HDFS-1580:Add interface for generic Write Ahead Logging mechanism)