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代码局部加载页面的内容,你希望通过改变当前页面的 ...
随机推荐
- At_speed_test
Logic BIST通过将很多的tester functionality放在CUT中,减少了test costs,但是更重要的一方面是at-speed testing. At-speed test包括 ...
- 设置Sql Agent运行Job时的执行账户
相信使用过Sql Server的人都应该知道,使用Sql Agent可以建立一些自动化Job来帮我们周期性地执行一些任务,其中执行SSIS包就是其中一个任务.而在SSIS包中有时候会去做读取文件等一些 ...
- HGE引擎之hgeSprite
一.hgeSprite类 hgeSprite是一个精灵实体的HGE帮助类. 1.构造函数 创建和初始化一个hgeSprite对象. hgeSprite(HTEXTURE tex, float x, f ...
- android 应用架构随笔四(View、ViewGroup)
View表示了用户界面的基本构建模块. 一个View占用了屏幕上的一个矩形区域并且负责界面绘制和事件处理.手机屏幕上所有看得见摸得着的都是View. Activity是四大组件中唯一一个用来和用户进行 ...
- linux设备驱动归纳总结(四):4.单处理器下的竞态和并发【转】
本文转载自:http://blog.chinaunix.net/uid-25014876-id-67005.html linux设备驱动归纳总结(四):4.单处理器下的竞态和并发 xxxxxxxxxx ...
- 【python cookbook】【数据结构与算法】15.根据字段将记录分组
问题:想根据字典或者对象实例的某个特定的字典(比如日期)来分组迭代数据 解决方案:itertools.groupby()函数在对数据进行分组时特别有用(前提是先以目标字典进行排序) rows = [ ...
- linux终端使用技巧
Shift+Ctrl+T:新建标签页Shift+Ctrl+W:关闭标签页Ctrl+PageUp:前一标签页Ctrl+PageDown:后一标签页Shift+Ctrl+PageUp:标签页左移Shift ...
- 配置SecondaryNameNode
一.SecondaryNameNode概念: 光从字面上来理解,很容易让一些初学者先入为主:SecondaryNameNode(snn)就是NameNode(nn)的热备进程.其实不是.ssn是HDF ...
- postgresql 热备与恢复
一. PostgreSQL热备份的过程一般为: 数据库中执行:pg_start_backup() ; 然后使用操作系统的tar或 cp命令拷贝 PostgreSQL数据文件. 数据库中执行:pg_st ...
- git 检出
1 git checkout branch 检出branch分支.要完成图8-1三个步骤,更新HEAD已指向新分支 以及用branch指向的树更新暂存区和工作区 2 git checkout 显示出工 ...