题目描述
计算积分
保留至小数点后5位。若积分发散,请输出"orz"。
输入输出格式
输入格式:
一行,包含一个实数,为a的值
输出格式:
一行,积分值或orz
输入输出样例
说明
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(, )));
}