2012 #5 History repeat itself
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
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 <stdio.h>
#include <string.h> long long a[],b[];
int main()
{
int T;
long long i,j,k;
long long n;
scanf("%d",&T);
a[]=;
for(i=;i<=;i++)
{
a[i]=a[i-]+i*(i*+);
}
for(i=;i<=;i++)
{
b[i]=i*i-i+;
}
while(T--)
{
scanf("%I64d",&n);
for(i=;i<=;i++)
{
if(n<b[i])
{
i--;
break;
}
}
long long x=(n-b[i]+)+i*i,y=a[i-]+i*(n-b[i]+);
printf("%I64d %I64d\n",x,y);
}
return ;
}
2012 #5 History repeat itself的更多相关文章
- HDU 4342——History repeat itself——————【数学规律】
History repeat itself Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. O ...
- hdu 4342 History repeat itself(数学题)
题目链接:hdu 4342 History repeat itself 题意: 让你找第a个非完全平方数m,并且求前m个数的开方向下取整的和. 题解: 第一个问题: 假设第a个非平方数是X,X前面有n ...
- 【HDU - 4342】History repeat itself(数学)
BUPT2017 wintertraining(15) #8C 题意 求第n(n<2^32)个非完全平方数m,以及\(\sum_{i=1}^m{\lfloor\sqrt i\rfloor}\) ...
- 二分查找+数学 HDOJ 4342 History repeat itself
题目传送门 题意:计算从1开始到第n个非完全平方数的开方和 分析:设第n个非完全平方数的值为a,x * x < a < (x+1) * (x+1),而且易得(tmp = sqrt (a) ...
- HDU 4342History repeat itself 数学
C - History repeat itself Time Limit:1000MS Memory Limit:32768KB Description Tom took the D ...
- [DE2i-150] 重建PCIe_Fundmental範例說明
以下資料的整理主要是做備忘錄,避免以後忘了,順便留給需要的人. ========================================== 本文主要是參考友晶科技的DE2i-150光碟裡面的 ...
- [转] JPA 2.0 with EclipseLink - 教程
原文: http://www.vogella.com/articles/JavaPersistenceAPI/article.html Lars Vogel Version 2.2 Copyright ...
- Deep Learning in a Nutshell: History and Training
Deep Learning in a Nutshell: History and Training This series of blog posts aims to provide an intui ...
- 使用HTML5的History API
HTML5 History API提供了一种功能,能让开发人员在不刷新整个页面的情况下修改站点的URL.这个功能很有用,例如通过一段JavaScript代码局部加载页面的内容,你希望通过改变当前页面的 ...
随机推荐
- 【转】转换到 COFF 期间失败: 文件无效或损坏
不知怎么本来编译好好的VS2010环境,忽然出现“转换到 COFF 期间失败: 文件无效或损坏”的链接错误.花了好多天,试了好多方法,最终解决了这个问题. 现在罗列一下这几种解决方案: 方案1 ...
- linux与windows的文本文件之间的转换
在CentOS中需要安装一个软件包:tofrodos 包里包含的命令可以用包管理工具列出包里的文件. 以 CentOS 的 rpm 为例: rpm -ql tofrodos 在ArchLinux中需要 ...
- Inside TSQL Querying - Chapter 2. Physical Query Processing
Summary Description The SQL language is spoken by most database experts, and all relational database ...
- 锋利的JQuery(六)
$.ajax():可以设定beforeSend.error.success.complete等 $.getScript():加载JS文件 $.getJSON():加载JSON文件 $.each():通 ...
- android小功能:checkbox使用自己的背景点击切换背景
xiazai_checkbox.xml <?xml version="1.0" encoding="utf-8"?> <selector xm ...
- 鸟哥的linux私房菜学习记录之认识系统服务(daemons)
- ubuntu下搭建JAVA开发环境【转】
转自:http://jingyan.baidu.com/article/86fae346b696633c49121a30.html JAVA开发环境是一种跨平台的程序设计语言,可以在windows.L ...
- 【JQGRID DOCUMENTATION】.学习笔记.1.安装jqGrid
前面介绍了怎么使用其MVC方式,很好用.不过,觉得还是只使用前段比较好. 1.1 如何安装 到http://www.trirand.com/blog/?page_id=6 下载. </html& ...
- du -sh
评估文件空间利用率: [root@vm-xiluhua][/home]$ du -sh /home 409M /home --exclude选项,排除指定模式的文件的大小 [root@vm-xiluh ...
- POSTGRESQL9.5之pg_rman工具
pg_rman是一款专门为postgresql设计的在线备份恢复的工具.其支持在线和基于时间点备份方式,还可以通过创建backup catalog来维护DB cluster备份信息. 看起来好像是模仿 ...