| ||||||||||
| 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 | |||||||||
哪位大牛帮我看看为什么TLE啊~~感激之至!#include <iostream>
using namespace std;
int n;
int main()
{
int k,i,j,num=0;
bool sign=1;
int test(float array[],float x);
float sum=0;
float a[10005]={0},l;
while(scanf("%d%d",&n,&k)!=EOF)
{
for(i=0;i<n;i++)
{
cin>>a[i];
sum+=a[i];
}
l=sum/k;
if(l<0.01)
sign=0;
else
num=test(a,l);
for(;num<k&&sign==1;)
{
l-=0.01;
if(l<0.01)
{
sign=0;
break;
}
num=test(a,l);
}
if(sign==0)
printf("0.00\n");
else
printf("%.2f\n",l);
return 0;
}
}
int test(float array[],float x)
{
int i,z=0;
for(i=0;i<n;i++)
z+=array[i]/x;
return z;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator