关于积分上限变大反而wa了
查看原帖
关于积分上限变大反而wa了
230875
Surge_of_Force楼主2022/4/17 20:18

RT,题目要求的积分上限是正无穷,但由于在20后面的积分对于答案的贡献很小,所以只积到20,于是为了提高精度我把上限变成了100,但为什么反而挂了,连样例都过不去,求大佬解答

附代码:

#include<bits/stdc++.h>
#define ll long long
#define lc(k) k<<1
#define rc(k) k<<1|1
//#define int long long
const int MAX=1e6+10;
const double Eps=1e-7;
using namespace std;
inline int read() {
  int fh = 1, res = 0; char ch = getchar();
  for(; !isdigit(ch); ch = getchar()) if(ch == '-') fh = -1;
  for(; isdigit(ch); ch = getchar()) res = (res << 3) + (res << 1) + (ch ^ '0');
  res = res * fh;
  return res;
}
inline void write(ll x) {
    if(x<0){putchar('-');x=-x;}
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
double a; 
double f(double x){return pow(x,a/x-x);}
double sip(double l,double r){return (r-l)*(f(l)+f(r)+4.0*f((l+r)/2.0))/6.0;}
double jf(double l,double r,double eps,double let)
{
	double mid=(l+r)/2.0;
	double jfl=sip(l,mid),jfr=sip(mid,r);
	if(fabs(jfl+jfr-let)<=eps*15) return jfl+jfr+(jfr+jfl-let)/15.0;
	return jf(l,mid,eps/2,jfl)+jf(mid,r,eps/2,jfr);
}
signed main()
{
	cin>>a;
	if(a<0.0) return puts("orz"),0;
	printf("%.5lf",jf(Eps,20.0,Eps,sip(Eps,20.0)));//这里改成100就wa烂了
	return 0;
}

2022/4/17 20:18
加载中...