题目描述

计算积分

保留至小数点后5位。若积分发散,请输出"orz"。

输入输出格式

输入格式:

一行,包含一个实数,为a的值

输出格式:

一行,积分值或orz

输入输出样例

输入样例#1: 复制

2.33
输出样例#1: 复制

1.51068

说明

a<=50

请注意时空限制。

观察到函数具有极强的收敛性

然后估算一下上界,直接上辛普森积分

// luogu-judger-enable-o2
#include<cstdio>
#include<cmath>
double a;
double F(double x) {
return pow(x, a / x - x);
}
double sim(double l, double r) {
return (F(l) + F(r) + * F((l + r) / )) * (r - l) / ;
}
double asr(double L, double R, double eps, double ans) {
double mid = (L + R) / ;
double LL = sim(L, mid), RR = sim(mid, R);
if(fabs(LL + RR - ans) <= * eps) return LL + RR;
return asr(L, mid, eps / , sim(L, mid)) + asr(mid, R, eps / , sim(mid, R));
}
main() {
#ifdef WIN32
freopen("a.in", "r", stdin);
#endif
scanf("%lf", &a);
if(a < ) {printf("orz");return ;}
printf("%.5lf", asr(1e-, , 1e-, sim(, )));
}

洛谷P4526 【模板】自适应辛普森法2(simpson积分)的更多相关文章

  1. 洛谷.4525.[模板]自适应辛普森法1(Simpson积分)

    题目链接 Simpson积分公式:\[\int_a^bf(x)dx\approx\frac{b-a}{6}\left[f(a)+f(b)+4f(\frac{a+b}{2})\right]\] 推导过程 ...

  2. 洛谷P4525 【模板】自适应辛普森法1(simpson积分)

    题目描述 计算积分 结果保留至小数点后6位. 数据保证计算过程中分母不为0且积分能够收敛. 输入输出格式 输入格式: 一行,包含6个实数a,b,c,d,L,R 输出格式: 一行,积分值,保留至小数点后 ...

  3. 洛谷 P4525 & P4526 [模板] 自适应辛普森积分

    题目:https://www.luogu.org/problemnew/show/P4525 https://www.luogu.org/problemnew/show/P4526 学习辛普森积分:h ...

  4. 洛谷P4526 【模板】自适应辛普森法2

    P4526 [模板]自适应辛普森法2 洛谷传送门 题目描述 计算积分 保留至小数点后5位.若积分发散,请输出"orz". 输入格式 一行,包含一个实数,为a的值 输出格式 一行,积 ...

  5. 洛谷P4525 【模板】自适应辛普森法1与2

    洛谷P4525 [模板]自适应辛普森法1 与P4526[模板]自适应辛普森法2 P4525洛谷传送门 P4525题目描述 计算积分 结果保留至小数点后6位. 数据保证计算过程中分母不为0且积分能够收敛 ...

  6. 洛谷4525 & 4526:【模板】自适应辛普森法——题解

    参考:https://phqghume.github.io/2018/05/19/%E8%87%AA%E9%80%82%E5%BA%94%E8%BE%9B%E6%99%AE%E6%A3%AE%E6%B ...

  7. P4526 【模板】自适应辛普森法2

    P4526 [模板]自适应辛普森法2 #include <bits/stdc++.h> using namespace std; ; double a; inline double f(d ...

  8. P4525 【模板】自适应辛普森法1

    P4525 [模板]自适应辛普森法1 #include <bits/stdc++.h> using namespace std; ; double a, b, c, d, l, r; in ...

  9. 洛谷P3373 [模板]线段树 2(区间增减.乘 区间求和)

    To 洛谷.3373 [模板]线段树2 题目描述 如题,已知一个数列,你需要进行下面两种操作: 1.将某区间每一个数加上x 2.将某区间每一个数乘上x 3.求出某区间每一个数的和 输入输出格式 输入格 ...

随机推荐

  1. Yii2用Gii自动生成Module+Model+CRUD

    1. 开启gii模块 common/config/main-local.php加入下面代码 return [ 'modules' => [ 'gii' => [ 'class' => ...

  2. js 更改对象中的属性名

    const json = JSON.parse(JSON.stringify(options).replace(/name/g,"label")); 注: 1.options是需要 ...

  3. C++ 的编译过程

    Recall that g++ is not actually the C++ compiler – it is a driver program that hides a lot of the co ...

  4. Dell R720上的系统安装问题的解决办法(关于RAID建立磁盘阵列的技术)

    摘要:本篇是本人在搭建大数量存储.搜索环境时,对于使用Dell PowerEdge R720 and R720xd作为服务器所遇到的一些问题进行的总结. 开始时,我们使用Dell提供的安装光盘(蓝色) ...

  5. WAS上配置数据源连接失败

    问题描述: 在节点 cnshh171Node01 上的服务器 server1 上, 对数据源 testj2cbug 执行的测试连接操作 由于以下异常 java.sql.SQLException: 调用 ...

  6. 【转】Linux vmstat命令实战详解

    好久没写博客了,上个月忙的晕头转向的实在没有心情.最近会发几篇PowerDNS的,先预告一下. 这篇是纯转的,原贴地址:http://www.cnblogs.com/ggjucheng/archive ...

  7. VMware ESXi 6.5安装

    vmware ESXI6.5安装 注意:我是用vmware模拟,选择镜像就可以进入.正常需要服务器做raid 然后安装的时候选择需要的硬盘 等待加载 按enter继续 F11同意并继续 等待扫描设备 ...

  8. linux nginx 配置php

    linux nginx 配置php   下载php源码 解压 configure ./configure --prefix=/usr/local/php --enable-fpm --with-mcr ...

  9. 挖矿病毒——test用户的ld-linux-x86-64任务

    表现:24核48线程的机器,极度占用系统CPU资源(约60%) 通过top查看之后可以看到排在首位的是test用户的ld-linux-x86-64任务. solution: 首先,/etc/passw ...

  10. YUV display in OpenGL

    http://stackoverflow.com/questions/1106741/need-help-with-yuv-display-in-opengl  I am having trouble ...