题目:https://www.luogu.org/problemnew/show/P4525

https://www.luogu.org/problemnew/show/P4526

学习辛普森积分:https://blog.csdn.net/VictoryCzt/article/details/80660113

代码如下:

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define eps 1e-8
using namespace std;
typedef double db;
db a,b,c,d,L,R;
db f(db x){return (c*x+d)/(a*x+b);}
db simp(db a,db b){return (b-a)/*(f(a)+*f((a+b)/)+f(b));}
db asr(db l,db r,db lst)
{
db mid=(l+r)/;
db ls=simp(l,mid),rs=simp(mid,r);
if(fabs(ls+rs-lst)<eps)return ls+rs;
else return asr(l,mid,ls)+asr(mid,r,rs);
}
db asme(db l,db r){return asr(l,r,simp(l,r));}
int main()
{
scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&L,&R);
printf("%.6f\n",asme(L,R));
return ;
}

P4525

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define eps 1e-8
using namespace std;
typedef double db;
db a;
db f(db x){return pow(x,a/x-x);}
db simp(db l,db r){return (r-l)/*(f(l)+*f((l+r)/)+f(r));}
db asr(db l,db r,db lst)
{
db mid=(l+r)/;
db ls=simp(l,mid),rs=simp(mid,r);
if(fabs(ls+rs-lst)<eps)return ls+rs;
return asr(l,mid,ls)+asr(mid,r,rs);
}
db asme(db l,db r){return asr(l,r,simp(l,r));}
int main()
{
scanf("%lf",&a);
if(a<){puts("orz"); return ;}
printf("%.5f\n",asme(eps,));
return ;
}

P4526

05-06 21:52