数据比较小时直接算,数据比较大时用公式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调和级数+欧拉常数的更多相关文章

  1. Harmonic Number(调和级数+欧拉常数)

    题意:求f(n)=1/1+1/2+1/3+1/4-1/n   (1 ≤ n ≤ 108).,精确到10-8    (原题在文末) 知识点:      调和级数(即f(n))至今没有一个完全正确的公式, ...

  2. C - Harmonic Number(调和级数+欧拉常数)

    In mathematics, the nth harmonic number is the sum of the reciprocals of the first n natural numbers ...

  3. Harmonic Number(调和级数+欧拉常数)

    In mathematics, the nth harmonic number is the sum of the reciprocals of the first n natural numbers ...

  4. Harmonic Number (调和级数+欧拉常数)题解

    Harmonic Number In mathematics, the nth harmonic number is the sum of the reciprocals of the first n ...

  5. [BZOJ 2048] [2009国家集训队]书堆 【调和级数】

    题目链接:BZOJ - 2048 题目分析 只有一本书时,这本书的重心落在桌子边缘上,伸出桌面的长度就是 1/2. 有两本书时,第一本书的重心就落在第二本书的边缘上,两本书的重心落在桌子边缘上,两本书 ...

  6. 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 + . ...

  7. 【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 ...

  8. Harmonic Number (LightOJ 1234)(调和级数 或者 区块储存答案)

    题解:隔一段数字存一个答案,在查询时,只要找到距离n最近而且小于n的存答案值,再把剩余的暴力跑一遍就可以. #include <bits/stdc++.h> using namespace ...

  9. LightOJ-1234-Harmonic Number-调和级数+欧拉常数 / 直接打表

    In mathematics, the nth harmonic number is the sum of the reciprocals of the first n natural numbers ...

随机推荐

  1. IO流入门-第七章-BufferedReader

    BufferedReader基本用法和方法示例 /* 字节 BufferedInputStream BufferedOutputStream 字符 BufferedReader:带有缓冲区的字符输入流 ...

  2. 第05章—Swagger2打造在线接口文档

    spring boot 系列学习记录:http://www.cnblogs.com/jinxiaohang/p/8111057.html 码云源码地址:https://gitee.com/jinxia ...

  3. soe结果为栅格的处理方式

    背景 ArcGIS for Server通过rest的形式提供功能在很多的时候,不能满足实际的需求.在日常工作中需要对Server的功能进行扩展,esri提供的一种方式就是使用soe的形式.官方给出的 ...

  4. SQL小练习

    1.现在有两张表订单表TB_ORDER,包括字段:order_id(订单号),username(用户名),amount(订单金额),order_time(下单时间), product_id(商品ID) ...

  5. Milking Time---poj3616(简单dp)

    题目链接:http://poj.org/problem?id=3616 题意:人从奶牛身上挤奶有m个时间段(1----n),每个时间段包含 s e f 表示从 s 到 e 的这段时间可以获得 f 单位 ...

  6. VGA显示

    VGA控制器的编写主要是了解VGA的显示标准和时序,如1024X768@60Hz,确定时钟频率(65MHz=1344X806X60),列像素时间等于时钟周期,扫描从左到右.从上到下(类似于电视扫描PA ...

  7. 移动端笔记——jQuery touch事件

    判断移动端还是pc端 function IsPC() { var userAgentInfo = navigator.userAgent; var Agents = new Array("A ...

  8. http的请求流程

    # !/usr/bin/env python # coding:utf-8 import socket def handle_request(client): buf = client.recv(10 ...

  9. 一个很牛的计算pi的c程序!

    C语言是面向过程的一种高级程序设计语言,它在世界范围内使用很广泛,而且很流行.很多大型的应用软件,基本上是用C语言所编写的.在对操作系统以及系统使用程序.需要对硬件进行操作的场合,C语言较其他的高级语 ...

  10. redis---在CentOS6.5下安装与配置

    本文详细介绍redis单机单实例安装与配置,服务及开机自启动.如有不对的地方,欢迎大家拍砖o(∩_∩)o (以下配置基于CentOS release 6.5 Final, redis版本3.0.2 [ ...