HDU 4342History repeat itself 数学
Time Limit:1000MS Memory Limit:32768KB
Description
As a result , Tom passed.
History repeat itself. You, the bad boy, also angered the Professor Lee when September Ends. You have to faced the problem too.
The problem comes that You must find the N-th positive non-square number M and printed it. And that's for normal bad student, such as Tom. But the real bad student has to calculate the formula below.
So, that you can really understand WHAT A BAD STUDENT YOU ARE!!
Input
To simplified the problem , The N will be within 2 31 and more then 0.
Output
Sample Input
1
3
6
10
Sample Output
5 7
8 13
13 28
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#include <typeinfo>
#include <map>
typedef long long ll;
using namespace std;
#define inf 10000000
inline ll read()
{
ll x=,f=;
char ch=getchar();
while(ch<''||ch>'')
{
if(ch=='-')f=-;
ch=getchar();
}
while(ch>=''&&ch<='')
{
x=x*+ch-'';
ch=getchar();
}
return x*f;
}
//***************************************************************
int main()
{
int t;
while(scanf("%d",&t)!=EOF)
{
while(t--)
{
ll n=read();
ll tmp=(ll)sqrt(n*1.0);
ll i=;
while((ll)sqrt(n+i)!=i)i++;
ll x=n+i;
ll flag=sqrt(n+i);
ll ans=;
for(ll i=;i<=flag;i++)
{
ans+=(i*i-(i-)*(i-))*(i-);
}
ans+=(x-flag*flag+)*flag;
cout<<x<<" "<<ans<<endl;
}
}
return ;
}
代码狗
HDU 4342History repeat itself 数学的更多相关文章
- HDU 4816 Bathysphere(数学)(2013 Asia Regional Changchun)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4816 Problem Description The Bathysphere is a spheric ...
- HDU 5584 LCM Walk 数学
LCM Walk Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5584 ...
- HDU 4336 Card Collector 数学期望(容斥原理)
题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=4336 题意简单,直接用容斥原理即可 AC代码: #include <iostream> ...
- HDU 5570 balls 期望 数学
balls Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5570 De ...
- hdu 4710 Balls Rearrangement (数学思维)
意甲冠军:那是, 从数0-n小球进入相应的i%a箱号.然后买一个新的盒子. 今天的总合伙人b一个盒子,Bob试图把球i%b箱号. 求复位的最小成本. 每次移动的花费为y - x ,即移动前后盒子编号 ...
- HDU 4790 Just Random 数学
链接:pid=4790">http://acm.hdu.edu.cn/showproblem.php?pid=4790 意:从[a.b]中随机找出一个数字x,从[c.d]中随机找出一个 ...
- HDU 1018-Big Number(数学)
Big Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...
- HDU 1840 Equations (简单数学 + 水题)(Java版)
Equations 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1840 ——每天在线,欢迎留言谈论. 题目大意: 给你一个一元二次方程组,a(X^2 ...
- HDU 5985 Lucky Coins 数学
Lucky Coins 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5985 Description Bob has collected a lot ...
随机推荐
- IIS 7.5 配置10W高并发
原文: http://www.myhack58.com/Article/sort099/sort0100/2012/35585.htm 原文: http://www.myhack58.com ...
- cdrecord光盘烧录工具
我们是透过 cdrecord 这个命令来进行文字介面的烧录行为,这个命令常见的选项有底下数个: [root@www ~]# cdrecord -scanbus dev=ATA <==查询烧录机位 ...
- Asp.net磁力链接搜索引擎源码-www.btboot.com
演示网址:www.btboot.com 源码出售中.... 联系QQ:313843288
- linux下搭建Nginx
Linux上搭建nginx,及简单配置 在上家公司都是运维安装nginx,到新公司后代码开发完成部署测试服务器要求自己装nginx,研究了好久安装好之后,到正式上线还要自己安装,索性把安装步骤自己记 ...
- java笔记--关于克隆技术
关于克隆 --如果朋友您想转载本文章请注明转载地址"http://www.cnblogs.com/XHJT/p/3884817.html"谢谢-- 1.假克隆 如: ObjectA ...
- HNU 12826 Balloons Colors
题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12826&courseid=268 #include&l ...
- jsp&servlet学习笔记
1.路径引用问题 一个css.jsp.html.或者javascript文件从从一个工程复制到另一工程,如果引用的时候使用的时相对路径,看似没有错误,但是却一直引用不进来,这时候要使用绝对路径,这样才 ...
- python模拟浏览器保存Cookie进行会话
#! /usr/bin/env python # -*-coding:utf- -*- import urllib import urllib2 import cookielib class NetR ...
- 73 [面试题]交换一个整数的二进制表示的奇偶位(swapOddEvenBits)
[本文链接] http://www.cnblogs.com/hellogiser/p/swap-odd-even-bits.html [分析] 假定一个数字是8位数,设为ABCDEFGH ABCDEF ...
- ReverseString
[本文链接] http://www.cnblogs.com/hellogiser/p/reverse-string.html reverse string [代码] C++ Code 123456 ...