2012 #5 History repeat itself
2015-08-30 19:40
543 查看
History repeat itself
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Submit Status Practice HDU 4342
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.
View Code
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Submit Status Practice HDU 4342
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.
#include <stdio.h> #include <string.h> long long a[70007],b[70007]; int main() { int T; long long i,j,k; long long n; scanf("%d",&T); a[0]=0; for(i=1;i<=70000;i++) { a[i]=a[i-1]+i*(i*2+1); } for(i=1;i<=70000;i++) { b[i]=i*i-i+1; } while(T--) { scanf("%I64d",&n); for(i=1;i<=70000;i++) { if(n<b[i]) { i--; break; } } long long x=(n-b[i]+1)+i*i,y=a[i-1]+i*(n-b[i]+2); printf("%I64d %I64d\n",x,y); } return 0; }
View Code
相关文章推荐
- 使用nginx的proxy_cache做网站缓存
- 程序包管理
- 质数中的质数 SDUT 3305
- Linux学习笔记——Btrfs文件系统的管理及应用
- 别人的确为了别人——价值观
- CentOS虚拟机web服务器实现windows本地实时测试
- 信息论基本公式汇总
- hdu5407CRB and Candies 求逆元
- 什么是大数据?
- 数据结构-线性表
- Swift入门篇-基本类型(3)
- Swift入门篇-基本类型(2)
- 开启java生活
- nginx负载均衡配置---nginx的学习之路
- RAID
- LeetCode之Maximum Product Subarray
- 面试题9:斐波那契数列
- Swift入门篇-基本类型(1)
- 2012 #3 Arcane Numbers
- 机房收费系统总结篇(3)--------验收总结