wojiaocbj

cbj

Apr 2nd, 2022
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. /*
  2.  Author: 曹北健
  3.  Result: AC Submission_id: 4270695
  4.  Created at: Sun Apr 03 2022 10:39:58 GMT+0800 (China Standard Time)
  5.  Problem_id: 5486   Time: 31    Memory: 2720
  6. */
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <math.h>
  11. #include <time.h>
  12. int main(){
  13.     double enter, jifen, res, seedx, seedy, sup;
  14.     int i, cnt = 0;
  15.     srand(time(0));
  16.     scanf("%lf", &enter);
  17.     sup = 1.0;
  18.     for(i = 1; i <= 150000; i++){
  19.         seedx = 1.0 * (rand() % 32768) / 32768.0 * enter;
  20.         seedy = 1.0 * (rand() % 32768) / 32768.0 * sup;
  21.         if(exp(-((seedx + 0.5) * (seedx + 0.5))) > seedy)
  22.             cnt++;
  23. }
  24.     jifen = (double)cnt / 150000.0 * enter * sup;
  25.     res = exp(-jifen);
  26.     printf("%.6lf", res);
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment