lightoj1234调和级数+欧拉常数
数据比较小时直接算,数据比较大时用公式1+1/2+...+1/n=inn+C+1/(2*n) ,C是欧拉常数0.5772156649
刚开始用的这个1+1/2+...+1/n=in(n+1)+C,结果一直wa。。。。
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f; int main()
{
// cout<<log(2)<<endl;
ios::sync_with_stdio(false);
cin.tie();
cout<<setiosflags(ios::fixed)<<setprecision();
ll t,cnt=;
cin>>t;
while(t--){
ll n;
cin>>n;
if(n>1e6)cout<<"Case "<<++cnt<<": "<<log(n)+C+1.0/(*n)<<endl;
else
{
double ans=;
for(ll i=;i<=n;i++)
ans+=(1.0/(double)i);
cout<<"Case "<<++cnt<<": "<<ans<<endl;
}
}
return ;
}
/*********************
12
1
2
3
4
5
6
7
8
9
90000000
99999999
100000000
*********************/
lightoj1234调和级数+欧拉常数的更多相关文章
- Harmonic Number(调和级数+欧拉常数)
题意:求f(n)=1/1+1/2+1/3+1/4-1/n (1 ≤ n ≤ 108).,精确到10-8 (原题在文末) 知识点: 调和级数(即f(n))至今没有一个完全正确的公式, ...
- C - Harmonic Number(调和级数+欧拉常数)
In mathematics, the nth harmonic number is the sum of the reciprocals of the first n natural numbers ...
- Harmonic Number(调和级数+欧拉常数)
In mathematics, the nth harmonic number is the sum of the reciprocals of the first n natural numbers ...
- Harmonic Number (调和级数+欧拉常数)题解
Harmonic Number In mathematics, the nth harmonic number is the sum of the reciprocals of the first n ...
- [BZOJ 2048] [2009国家集训队]书堆 【调和级数】
题目链接:BZOJ - 2048 题目分析 只有一本书时,这本书的重心落在桌子边缘上,伸出桌面的长度就是 1/2. 有两本书时,第一本书的重心就落在第二本书的边缘上,两本书的重心落在桌子边缘上,两本书 ...
- Harmonic Number 求Hn; Hn = 1 + 1/2 + 1/3 + ... + 1/n; (n<=1e8) T<=1e4; 精确到1e-8; 打表或者调和级数
/** 题目:Harmonic Number 链接:https://vjudge.net/contest/154246#problem/I 题意:求Hn: Hn = 1 + 1/2 + 1/3 + . ...
- 【Canvas】勾画调和级数Harmonic series 曲线 y=1+1/2+1/3+1/4+1/5+1/6+1/7+1/8+....
相关资料:https://baike.baidu.com/item/%E8%B0%83%E5%92%8C%E7%BA%A7%E6%95%B0/8019971?fr=aladdin 调和级数(英语:Ha ...
- Harmonic Number (LightOJ 1234)(调和级数 或者 区块储存答案)
题解:隔一段数字存一个答案,在查询时,只要找到距离n最近而且小于n的存答案值,再把剩余的暴力跑一遍就可以. #include <bits/stdc++.h> using namespace ...
- LightOJ-1234-Harmonic Number-调和级数+欧拉常数 / 直接打表
In mathematics, the nth harmonic number is the sum of the reciprocals of the first n natural numbers ...
随机推荐
- 原!mysql5.6 存储过程 批量建表
由于业务需求,需要按天分表,因此写了个存储过程,根据时间生成表. 根据createTime 的时间,以及 while循环的变量设置范围,生成该指定日期及之后的多张表. BEGIN ); ); ; '; ...
- 【我的Android进阶之旅】如何在浏览器上使用Octotree插件树形地展示Github项目代码?
前言 最近有个同事看到我打开Github项目时,浏览器上的展示效果是树形的,于是他问我这个是什么浏览器插件,我告诉他是Octotree插件.现在我就来介绍介绍这款Octotree插件. 效果对比 1. ...
- Flask(2)- 装饰器的坑及解决办法、flask中的路由/实例化配置/对象配置/蓝图/特殊装饰器(中间件、重定义错误页面)
一.装饰器的坑以及解决方法 1.使用装饰器装饰两个视图函数,代码如下 from flask import Flask, redirect, render_template, request, sess ...
- (转)基于深度学习的目标检测技术演进:R-CNN、Fast R-CNN、Faster R-CNN
object detection我的理解,就是在给定的图片中精确找到物体所在位置,并标注出物体的类别.object detection要解决的问题就是物体在哪里,是什么这整个流程的问题.然而,这个问题 ...
- io.Writer
var w io.Writer // 设置为你的 io.Writer var b bytes.Buffer fmt.Fprint(&b, "Hello World") w ...
- Android学习九---OpenCV4android org.opencv.feature2d
不管是在识别,配准等应用中,提取图像的特征都是很关键的一环,提取特征是先找出图像的关键点(如角点,边缘点等),然后用描述子来描述这些点,最后整幅图像就可以表示成一个特征向量,特征向量就可以利用在后续识 ...
- beego——错误处理
beego通过Redirect方法来进行跳转: func (this *AddController) Get() { this.Redirect("/", 302) } 如何终止此 ...
- Ecstore 会员中心 菜单添加一项
1.会员中心 添加菜单 ecstore_合并支付总结_会员中心添加菜单_20160113 class : b2c_ctl_site_member (图 1) 第一步: (图1) ...
- Bootstrap 简介二
什么是 Bootstrap? Bootstrap 是一个用于快速开发 Web 应用程序和网站的前端框架.Bootstrap 是基于 HTML.CSS.JAVASCRIPT 的. 历史 Bootstra ...
- VS2017 下使用 git. git服务器使用gitblit
注意事项: 创建的GIT不要包括有中文, 不然会不成功的..... gitblit安装及配置及客户端下载略过...... 可参考: https://www.cnblogs.com/jeremylee ...