当前位置:网站首页>【Luogu_P4820】 【国家集训队】书堆【数学】【物理】【调和级数】
【Luogu_P4820】 【国家集训队】书堆【数学】【物理】【调和级数】
2022-07-15 18:16:00 【VL——MOESR】

思路:
首先通过物理知识,我们知道是要求
m 2 ∗ ( 1 + 1 2 + 1 4 + 1 6 … … + 1 n ) \frac{m}{2}*(1+\frac{1}{2}+\frac{1}{4}+\frac{1}{6}……+\frac{1}{n}) 2m∗(1+21+41+61……+n1)
里面这个东西用调和级数搞掉。
注意最后答案是不能取到的,所以要往下取一个
c o d e code code
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const double eps = 1e-6;
const double euler = 0.5772156649015328;
long long n, m;
int main() {
scanf("%lld%lld", &n, &m);
if(n<=1e7) {
double s=0;
for(int i = 1; i <= n; i ++)
s=s+(1.0/i);
cout<<round(s * m / 2 - 0.5 - eps);
}
else {
double s = (log(n) + euler) * m / 2 - 0.5 - eps;
cout<<round(s);
}
return 0;
}
边栏推荐
- If in SQL determines the error
- 使用POI替换word中的特定字符/文字改进版
- 【每日一题】558. 四叉树交集
- "Smart factory" goes online, breaking the traditional factory digital transformation
- Qt(四)使用代码与UI文件混合开发
- Qt(五)元对象特性
- 当使用single-branch clone仓库后,如何添加跟踪的远程分支?
- Qt(六)数值与字符串转换
- [深入研究4G/5G/6G专题-37]: URLLC-8-《3GPP URLLC相关协议、规范、技术原理深度解读》-2-网络架构、时延分析与URLLC载波部署形态
- MySQL 关于 zip安装包 的安装过程
猜你喜欢

Develop command line tools

档案的逻辑 | 全宗区分和示例

一文搞懂Go整合captcha实现验证码功能

A-F codeworks round 806 (div.4) A-F problem solution and code

STL值string学习

GET 请求和 POST 请求的区别和使用

Torch in pytoch Sort() and torch Argsort() function parsing

clickhouse 20.x 分布式表测试与chproxy的部署(二)

Qt(十三)QChart绘制折线图

SAP S/4HANA New Simplified Data Model (NSDM) 模型介绍
随机推荐
YesDev:轻松协作每一个项目
华为通用卡证识别功能,一键实现多种卡绑定
C语言:数的阶乘递归实现
Swift value type and reference type
BigDecimal compare size
Replace specific characters / text improvements in word with POI
Solutions to SSL and time zone errors when using JDBC to operate the database
木马病毒清除方式
SAP s/4hana new simplified data model (NSDM) model introduction
DNS attack protection principle
谐云课堂 | 敏捷开发流程及项目实战分享
EasyGBS平台编辑设备管理分组时,出现崩溃该如何解决?
开发那些事儿:如何解决RK芯片视频处理编解码耗时很长的问题?
Test the speed characteristics of optical flow sensor
A-F codeworks round 806 (div.4) A-F problem solution and code
Lambda表达式二:方法引用
一文搞懂│什么是跨域?如何解决跨域?
CRMEB Pro v1.4,让用户体验更出彩!
单身杯,Web:web签到
MYSQL和 ORACLE 的常见区别(二)