| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
大家帮忙看看这个程序有什么问题呢,谢谢!#include <stdio.h>
#include <math.h>
#include <string.h>
#define M 1000000
#define PI 3.141592653589793
int num[151];
double cal(double p)
{
double dx=0.0001,c=1.0/sqrt(2*PI),x0=0,s=0.5,t,m;
if (p>=0.5){
while(x0<=5&&s<=p){
m=x0+dx/2.0;
t=exp(-(m*m)/2.0)*dx*c;
s=s+t;
x0+=dx;
}
//x0-=dx;
}
else{
while(x0>=-5&&s>=p){
m=x0-dx/2.0;
t=exp(-(m*m)/2.0)*dx*c;
s=s-t;
x0-=dx;
}
//x0+=dx;
}
return x0;
}
int main()
{
int i,n,m,sc,j,k,first=1,sp;
double p,sp1,x;
freopen("input.txt","r",stdin);
//printf("%lf\n",cal(0.999978));
while(scanf("%d",&n)!=EOF&&n){
if (!first) printf("\n");
first=0;
for(i=0;i<n;i++){scanf("%d",&sc);num[sc]++;}
scanf("%d",&m);
for(i=0;i<m;i++){
scanf("%d",&sc);
k=0;
for(j=0;j<sc;j++) k+=num[j];
p=k/double(n);
x=cal(p);
sp1=500.0+100.0*x;
if (sp1<=100) sp=100;
else if (sp1>100&&sp1<=501) sp=sp1;
else if (sp1>501&&sp1<=900) sp=sp1+0.5;
else sp=900;
printf("%d\n",sp);
}
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator