Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: 曹北健
- Result: AC Submission_id: 4270695
- Created at: Sun Apr 03 2022 10:39:58 GMT+0800 (China Standard Time)
- Problem_id: 5486 Time: 31 Memory: 2720
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <time.h>
- int main(){
- double enter, jifen, res, seedx, seedy, sup;
- int i, cnt = 0;
- srand(time(0));
- scanf("%lf", &enter);
- sup = 1.0;
- for(i = 1; i <= 150000; i++){
- seedx = 1.0 * (rand() % 32768) / 32768.0 * enter;
- seedy = 1.0 * (rand() % 32768) / 32768.0 * sup;
- if(exp(-((seedx + 0.5) * (seedx + 0.5))) > seedy)
- cnt++;
- }
- jifen = (double)cnt / 150000.0 * enter * sup;
- res = exp(-jifen);
- printf("%.6lf", res);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment