题意:给定n,求前 n 项 1/(k*k) 的和。

析:由于这个极限是 PI * PI / 6,所以我们可以找到分界点,然后计算就好。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e3 + 5;
const int mod = 1e9 + 7;
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, 1, 0, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
} double a[34405]; int main(){
for(int i = 1; i <= 34403; ++i)
a[i] = (1.0/(1.0*i*i)) + a[i-1]; double x;
while(scanf("%lf", &x) == 1){
if(x >= 110292) printf("1.64493\n");
else if(x >= 52447) printf("1.64492\n");
else if(x >= 34403) printf("1.64491\n");
else printf("%.5f\n", a[(int)x]);
}
return 0;
}

HDU 5879 Cure (数论)的更多相关文章

  1. HDU 5879 Cure

    Cure Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  2. HDU 5879 Cure -2016 ICPC 青岛赛区网络赛

    题目链接 题意:给定一个数n,求1到n中的每一项的平方分之一的累加和. 题解:题目没有给数据范围,而实际上n很大很大超过long long.因为题目只要求输出五位小数,我们发现当数大到一定程度时值是固 ...

  3. Cure HDU - 5879(预处理+技巧)

    Cure Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  4. hdu GuGuFishtion 6390 数论 欧拉函数

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=6390 直接开始证明: 我们设…………………………………….....…...............………… ...

  5. HDU 1299 基础数论 分解

    给一个数n问有多少种x,y的组合使$\frac{1}{x}+\frac{1}{y}=\frac{1}{n},x<=y$满足,设y = k + n,代入得到$x = \frac{n^2}{k} + ...

  6. HDU 5317 RGCDQ (数论素筛)

    RGCDQ Time Limit: 3000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u Submit Status ...

  7. HDU 1495 非常可乐(数论,BFS)

    非常可乐 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  8. HDU 1722 Cake (数论 gcd)(Java版)

    Big Number 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1722 ——每天在线,欢迎留言谈论. 题目大意: 给你两个数 n1,n2 . 然后 ...

  9. L - LCM Walk HDU - 5584 (数论)

    题目链接: L - LCM Walk HDU - 5584 题目大意:首先是T组测试样例,然后给你x和y,这个指的是终点.然后问你有多少个起点能走到这个x和y.每一次走的规则是(m1,m2)到(m1+ ...

随机推荐

  1. CAS 跨域原理

    http://www.blogjava.net/rain1102/articles/227739.html CAS(Central Authentication Service) 是 Yale 大学发 ...

  2. 反混淆:恢复被OLLVM保护的程序

    译者序: OLLVM作为代码混淆的优秀开源项目,在国内主流app加固应用中也经常能看到它的身影,但是公开的分析研究资料寥寥.本文是Quarkslab团队技术博客中一篇关于反混淆的文章,对OLLVM项目 ...

  3. Linux学习系列之Iptables

    iptables命令是Linux上常用的防火墙软件,是netfilter项目的一部分.可以直接配置,也可以通过许多前端和图形界面配置. 语法 iptables(选项)(参数) 选项 -t<表&g ...

  4. 在chrome中屏蔽百度推荐

    在chrome中屏蔽百度推荐 方法1:可以使用adblock plus来进行屏蔽: 需要将chrome的扩展程序打开为调试者模式: 下载地址:http://chromecj.com/productiv ...

  5. IP协议解读(二)

    IP协议是TCP协议栈中的核心协议,也是网络编程的基础之中的一个. 我们接着在IP协议解读(一)继续学习 网络层作用 IP分片: IP数据报的长度超过帧的MTU时,将会被分片传输. 分片可能发生在发送 ...

  6. Effective C++ 条款四 确定对象被使用前已被初始化

    1.对于某些array不保证其内容被初始化,而vector(来自STL)却有此保证. 2.永远在使用对象前初始化.对于无任何成员的内置类型,必须手工完成.      int x = 0;      c ...

  7. Mac 下配置 Cocos2d-x 3-x android 的环境

    本人初学Cocos2d 3-x,环境配置,搭建android环境弄了好长时间,走了不少弯路,翻阅了好多人的博客和文档,包括官方文档讲的似乎有些似懂非懂,好多依然是旧的版本,所以把我的整个过程梳理一下. ...

  8. Objective-C面向对象-对象和类

    文章都是先由本人个人博客:孙占兴:www.teilim.com,先更新,随后CSDN博客才会更新,掌握第一动态请关注本人主站. 原文链接:http://www.teilim.com/objective ...

  9. PowerDesigner逆向工程,从SQL Server数据库生成Physical Model

    提前声明:这种方式貌似只能是Power Designer安装在数据库服务器的时候才可以,因为我按照成功的这个再去从本机逆向连接远程服务器的时候,一直提示:test failed......不讲了,尴尬 ...

  10. 阿里巴巴Java开发手册(开发规范)——编程规约笔记

    2.常量规约 [推荐]如果变量值仅在一个范围内变化用Enum类. 如果还带有名称之外的延伸属性,必须使用Enum类, 下面正例中的数字就是延伸信息,表示星期几. 正例: public Enum{ MO ...