Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: 曹北健
- Result: AC Submission_id: 4279111
- Created at: Wed Apr 06 2022 07:37:06 GMT+0800 (China Standard Time)
- Problem_id: 5486 Time: 14 Memory: 2672
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <string.h>
- #include <ctype.h>
- #pragma warning(disable:4996)
- typedef long long LL;
- typedef unsigned long long ULL;
- double lam(double t){
- return exp(-((t + 0.5) * (t + 0.5)));
- }
- double simpson(int ndiv, double lb, double ub, double(*pfunc)(double)){
- double h = (ub - lb) / ndiv;
- double s = pfunc(lb) + pfunc(ub);
- int i;
- for(i = 1; i < ndiv; i += 2){
- s += 4 * pfunc(lb + i * h);
- }
- for(i = 2; i < ndiv - 1; i += 2){
- s += 2 * pfunc(lb + i * h);
- }
- return s * h / 3.;
- }
- int main(){
- double ub;
- scanf("%lf", &ub);
- printf("%.6f\n", exp(-simpson(114514, 0, ub, lam)));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment