2 条题解
-
0
#include<bits/stdc++.h>//暴力模拟80分 using namespace std; const double eps=1e-10; double a,b,c,L,R; double f(double x) { return a*x*x+b*x+c; } double simpson(double l,double r) { return (r-l)*( f(l)+f(r)+4*f( (l+r)/2 ) )/6; } int main() { //freopen("a.in","r",stdin);freopen("a.out","w",stdout); scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&L,&R); double ans=0; for(double i=L;i<=R; i+=0.000001) ans+= f(i+0.0000005)*0.000001; printf("%.1lf\n",ans ); return 0; }#include<bits/stdc++.h>//正解 辛普森公式 using namespace std; const double eps=1e-10; double a,b,c,L,R; double f(double x) { return a*x*x+b*x+c; } double simpson(double l,double r) { return (r-l)*( f(l)+f(r)+4*f( (l+r)/2 ) )/6; } int main() { freopen("a.in","r",stdin);freopen("a.out","w",stdout); scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&L,&R); printf("%.1lf\n",simpson(L,R) ); return 0; }
-
0
#include<bits/stdc++.h>//暴力模拟80分 using namespace std; const double eps=1e-10; double a,b,c,L,R; double f(double x) { return a*x*x+b*x+c; } double simpson(double l,double r) { return (r-l)*( f(l)+f(r)+4*f( (l+r)/2 ) )/6; } int main() { //freopen("a.in","r",stdin);freopen("a.out","w",stdout); scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&L,&R); double ans=0; for(double i=L;i<=R; i+=0.000001) ans+= f(i+0.0000005)*0.000001; printf("%.1lf\n",ans ); return 0; }
#include<bits/stdc++.h>//正解 辛普森公式 using namespace std; const double eps=1e-10; double a,b,c,L,R; double f(double x) { return a*x*x+b*x+c; } double simpson(double l,double r) { return (r-l)*( f(l)+f(r)+4*f( (l+r)/2 ) )/6; }int main() { freopen("a.in","r",stdin);freopen("a.out","w",stdout); scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&L,&R); printf("%.1lf\n",simpson(L,R) ); return 0; }
</p>
- 1
信息
- ID
- 501
- 时间
- 2000ms
- 内存
- 128MiB
- 难度
- 7
- 标签
- 递交数
- 59
- 已通过
- 15
- 上传者