HDU 4342 History repeat itself
来源:互联网 发布:基础网络 腾讯云 编辑:程序博客网 时间:2024/05/21 15:38
History repeat itself
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 488 Accepted Submission(s): 244
Problem Description
Tom took the Discrete Mathematics course in the 2011,but his bad attendance angered Professor Lee who is in charge of the course. Therefore, Professor Lee decided to let Tom face a hard probability problem, and announced that if he fail to slove the problem there would be no way for Tom to pass the final exam.
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!!
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
There is a number (T)in the first line , tell you the number of test cases below. For the next T lines, there is just one number on the each line which tell you the N of the case.
To simplified the problem , The N will be within 231 and more then 0.
To simplified the problem , The N will be within 231 and more then 0.
Output
For each test case, print the N-th non square number and the result of the formula.
Sample Input
413610
Sample Output
2 25 78 1313 28
不知为何用sqrt求那个n的时候就WA。。。哎,了解的不够!
#include <stdio.h>#include <string.h>#include <stdlib.h>#include <algorithm>using namespace std;int main( ){ int cas; __int64 sum , n , m , ans; scanf("%d",&cas); while( cas-- ) { sum = 0; n = 1; scanf("%I64d",&m); while( n * (n+1) < m ) n++; ans = n+m; sum = (ans - n*n + 1) * n ; while( --n ) { sum += n * (2*n+1); } printf("%I64d %I64d\n",ans , sum); } return 0;}
- hdu 4342 History repeat itself
- HDU 4342 History repeat itself
- HDU 4342 History repeat itself
- HDU 4342 - History repeat itself
- HDU 4342 History repeat itself 模拟
- hdu 4342 History repeat itself 模拟题
- HDU 4342 ——History repeat itself
- HDU 4342 History repeat itself 简单公式
- hdu 4342 History repeat itself(思维)
- HDOJ 4342 History repeat itself
- HDOJ 4342 History repeat itself
- hdu - 4342 - History repeat itself - 纯数学水题
- 【杂题】 HDOJ 4342 History repeat itself
- HDOJ 4342History repeat itself(数学)
- HDU4342 History repeat itself
- History repeat itself 解题
- HDU 4342 History repeat itself 2012 Multi-University Training Contest 5
- HDU4342 History repeat itself数学规律题
- rcp(插件开发)如何打开首选项页(open preferences page)
- Lambda表达式
- 第一篇
- Android ilbc 语音对话示范(四)发送方代码
- objective-c今日笔记
- HDU 4342 History repeat itself
- [递归]3.4.2 American Heritage
- FCKeditor 学习总结
- 菜单 图标
- HDU 1068 Girls and Boys 二分最大独立集
- sql server2005附加数据库时遇到的问题
- Android Launcher开发(一)LiveFolder(实时文件夹) 完全解析
- 二叉树的顺序存贮结构
- BroadCastReceiver 与 startService