
欧拉公式
发布日期:2021-05-07 23:28:38
浏览次数:19
分类:精选文章
本文共 1212 字,大约阅读时间需要 4 分钟。
欧拉公式:log(n)+y+1.0/(2*n)
欧拉常数y:0.57721566490153286060651209题:
In mathematics, the nth harmonic number is the sum of the reciprocals of the first n natural numbers:

In this problem, you are given n, you have to find Hn.
Input
Input starts with an integer T (≤ 10000), denoting the number of test cases.Each case starts with a line containing an integer n (1 ≤ n ≤ 10^8).
Output
For each case, print the case number and the nth harmonic number. Errors less than 10^-8 will be ignored.Sample Input
12 1 2 3 4 5 6 7 8 9 90000000 99999999 100000000Sample Output
Case 1: 1 Case 2: 1.5 Case 3: 1.8333333333 Case 4: 2.0833333333 Case 5: 2.2833333333 Case 6: 2.450 Case 7: 2.5928571429 Case 8: 2.7178571429 Case 9: 2.8289682540 Case 10: 18.8925358988 Case 11: 18.9978964039 Case 12: 18.9978964139注:欧拉公式只有在n值大的时候比较准确
#include#include using namespace std;const double y=0.57721566490153286060651209;int main(){ int t,o=0; double a[10005]; a[1]=1; for(int i=2;i<=10000;++i) { a[i]=a[i-1]+1.0/i; } scanf("%d",&t); while(t--) { o++; long n; double s=0; scanf("%d",&n); if(n<10000) { s=a[n]; } else { s=log(n)+y+1.0/(2*n); } printf("Case %d: %.10lf\n",o,s); } return 0; }
发表评论
最新留言
关注你微信了!
[***.104.42.241]2025年04月18日 15时28分29秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
使用Power BI构建数据仓库与BI方案
2021-05-09
Django认证系统并不鸡肋反而很重要
2021-05-09
tep用户手册帮你从unittest过渡到pytest
2021-05-09
12张图打开JMeter体系结构全局视角
2021-05-09
Spring Boot 2.x基础教程:构建RESTful API与单元测试
2021-05-09
[UWP 自定义控件]了解模板化控件(1):基础知识
2021-05-09
UWP 自定义控件:了解模板化控件 系列文章
2021-05-09
[UWP]从头开始创建并发布一个番茄钟
2021-05-09
WinUI 3 Preview 3 发布了,再一次试试它的性能
2021-05-09
使用命令把SpringBoot项目打包成可运行的jar包(简洁,操作性强)
2021-05-09
List数组排序
2021-05-09
VMware vSphere 离线虚拟机安装 BIND 9
2021-05-09
dojo/request模块整体架构解析
2021-05-09
Javascript定时器学习笔记
2021-05-09
dojo的发展历史
2021-05-09
Python存储系统(Redis)
2021-05-09
C语言指针收藏
2021-05-09
C#搞个跨平台的桌面NES游戏模拟器
2021-05-09
手把手教你安装Eclipse最新版本的详细教程 (非常详细,非常实用)
2021-05-09
《带你装B,带你飞》pytest成魔之路4 - fixture 之大解剖
2021-05-09