HDU 5879 Cure (数论)
题意:给定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 (数论)的更多相关文章
- HDU 5879 Cure
Cure Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- HDU 5879 Cure -2016 ICPC 青岛赛区网络赛
题目链接 题意:给定一个数n,求1到n中的每一项的平方分之一的累加和. 题解:题目没有给数据范围,而实际上n很大很大超过long long.因为题目只要求输出五位小数,我们发现当数大到一定程度时值是固 ...
- Cure HDU - 5879(预处理+技巧)
Cure Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- hdu GuGuFishtion 6390 数论 欧拉函数
题目:http://acm.hdu.edu.cn/showproblem.php?pid=6390 直接开始证明: 我们设…………………………………….....…...............………… ...
- HDU 1299 基础数论 分解
给一个数n问有多少种x,y的组合使$\frac{1}{x}+\frac{1}{y}=\frac{1}{n},x<=y$满足,设y = k + n,代入得到$x = \frac{n^2}{k} + ...
- HDU 5317 RGCDQ (数论素筛)
RGCDQ Time Limit: 3000MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64u Submit Status ...
- HDU 1495 非常可乐(数论,BFS)
非常可乐 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submi ...
- HDU 1722 Cake (数论 gcd)(Java版)
Big Number 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1722 ——每天在线,欢迎留言谈论. 题目大意: 给你两个数 n1,n2 . 然后 ...
- L - LCM Walk HDU - 5584 (数论)
题目链接: L - LCM Walk HDU - 5584 题目大意:首先是T组测试样例,然后给你x和y,这个指的是终点.然后问你有多少个起点能走到这个x和y.每一次走的规则是(m1,m2)到(m1+ ...
随机推荐
- k-svd字典学习,稀疏编码
1. K-SVD usage: Design/Learn a dictionary adaptively to betterfit the model and achieve sparse s ...
- Solidedge如何新建参考平面 参考面
1 建立平行平面 点击平行平面 点击参考平面,输入相对距离 2 建立成角平面 先选择基准面,再选则旋转轴(第二次点击一个平面,该平面与基准面相交形成的直线即为旋转轴) 输入角度即可完成(鼠标左 ...
- SolidEdge如何绘制阵列之后取消掉某一些
在最后一步点击"抑制事件",然后可以在被阵列的圆形上单击,被抑制的圆形变成灰色
- 创建一个简单的 http 服务器
创建一个简单的 http 服务器 直接在 目录下运行 当前的目录即可是root 目录 默认端口8000 应该可以加参数修改端口号 Python2 python -m SimpleHTTPServer ...
- poj2595(凸包)
Min-Max Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2192 Accepted: 502 Descriptio ...
- Cocos2d-x 精灵碰撞检測(方法一)
声明函数碰撞检測函数,两个精灵和重写update bool isCollision( CCPoint p1,CCPoint p2,int w1,int h1,int w2,int h2 ); CCSp ...
- 这样看ACM是不是更好?
如果搞ACM只是为了拿奖,为了保研,这样太功利,整个过程都会变得没意思.我说过我同时看中过程和结果. 其实ACM解题也不是那么没意思,每次AC都有一种非常棒的成就感,每个题目就像是一个解谜游戏,完成了 ...
- iOS开发之---判断是否是手机号
iOS开发之---判断是否是手机号
- UltraEdit中使用正则表达式-简单用法
UltraEdit中使用正则表达式 1.认识正则表达式语法: 正则表达式 (UltraEdit Syntax): % 匹配行首 - 表明要搜索的字符串一定在行首. $ 匹配行尾 - 表明要搜索的字符串 ...
- Jetty的JNDI数据源
一. 此处绑定的数据源是以 DBCP 为实现.首先必须将数据库驱动(这里用了MYSQL数据库)和DBCP所需要的 Jar 包复制到 Jetty 根目录的 lib 目录下.DBCP主要需要以下3个文件: ...