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代码局部加载页面的内容,你希望通过改变当前页面的 ...
随机推荐
- android之‘com.example.android.apis.view’的代码段
1.AutoCompleteTextView ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, and ...
- svn使用相关问题:eclipse插件,加锁,解锁,偷锁,更新不了,记住密码
svn使用相关问题:eclipse插件,加锁,解锁,偷锁,更新不了,记住密码 获取锁的时候可以看下 是谁锁住了,让对方提交解锁,如果是给离职人员锁住需要使用偷锁的方式先解锁再提交偷锁处理办法:选中该文 ...
- Failed to read auto-increment value from storage engine, Error Number: 1467
重设auto_increment:ALTER TABLE tableName auto_increment=number
- java 调用grads 自动批量生成图片
将 -lbcx 命令 后面的4个参数(gs文件名.参数1.参数2.参数3) 放在单引号里面就可以执行了.
- Mysql服务器相互作用的通讯协议包括TCP/IP,Socket,共享内存,命名管道
MySQL实现了四种通信协议 TCP/IP协议,通常我们通过来连接MySQL,各种主要编程语言都是根据这个协议实现了连接模块 Unix Socket协议,这个通常我们登入MySQL服务器中使用这个协议 ...
- Content Delivery Network
Coding Standards & Best Practices 7 Reasons to use a Content Delivery Network CDN公共库汇总
- [转]Win7下安装配置sharepoint server 2010
转自:http://blog.sina.com.cn/s/blog_5d93d7aa010151lp.html 要开发SharePoint 2010应用程序,开发人员必须构建一个SharePoint ...
- linux,shell输入反斜杠显示'W'。
linux,shell输入反斜杠显示'W'. solution: 字体必须为"Courier New".
- java JPEGImageEncoder;图像处理
在Eclipse中处理图片,需要引入两个包: import com.sun.image.codec.jpeg.JPEGCodec; import com.sun.image.codec.jpeg.JP ...
- python正则表达式之元字符介绍
python中元字符及其含义如下: 元字符 含义 . 匹配除换行符以外的任意一个字符 ^ 匹配行首 $ 匹配行尾 ? 重复匹配0次或1次 * 重复匹配0次或更多次 + 重复匹配1次或更多次 {n,} ...