当前位置: 代码迷 >> 综合 >> BUPT OJ190 Improper Integral
  详细解决方案

BUPT OJ190 Improper Integral

热度:57   发布时间:2024-01-12 05:25:38.0

题目描述

In advanced mathematics, Improper integral is a problem that is so hard to solve! But thanks to computer programming, we can solve these problems in the given precision easily. Today, Small Qiang is facing a simple and common improper integral problem, which asks him to determine the cumulative distribution function of normal distribution defined below:


But Small Qiang is busy playing basketball, so he is asking you for help! Please determine  Φ(x)  with a given x.

输入格式

In the first line, there is one integer  T(T<500) . In the following T lines, each contains one real number  x(0.0x5.0) .

输出格式

For each x, output a real number  Φ(x)  which keeps to five decimal places.

输入样例

1
0.0

输出样例

0.50000

热身赛R4AC率最低的K题, 题意简单粗暴, 计算正态分布的定积分

出题人本意是用数值积分或者泰勒级数吧, 忘记了C/C++中有个误差函数erf(). 对于误差函数的定义如下


只要稍作变换就可以得到题目所需要的答案, 易得:


顺便这次R4完全是数学专场啊233, 中途6题时一度冲到第一, 最后还是因为怎么也做不出G掉下来了, 不得不说这题目配置对编程不行的我来说简直是福音~~

不过数学题真心写不出什么题解来, 证明可以写的东西太多, 直接推出一个公式又略显草率, 所以前面很多数学/博弈题我就不打算写题解了, 见谅.



/*
USER_ID: test#birdstorm
PROBLEM: 190
SUBMISSION_TIME: 2014-03-14 23:04:53
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>main()
{int i, j, t;double x;scanf("%d",&t);while(t--){scanf("%lf",&x);printf("%.5lf\n",0.5+0.5*erf(x/sqrt(2)));}return 0;
}


当然数值积分的方法也并不繁琐, 而且更能用于解决一般情况, 这题只是一个意外的数学解, 老老实实的二次曲线逼近才是正解.