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 |
结果是截断不是四舍五入In Reply To:一直 wa, ft! 给点数据吧. Posted by:slwgu at 2005-10-23 22:16:51 > #include <stdio.h> > #include <iostream.h> > #include <string.h> > #include <stdlib.h> > > int n; > double len; > double maxt; > int maxi; > double t; > double v; > double x[32000]; > char direct[32000]; > char str[32000][251]; > > int num[32000]; > > int cmp(void const *a, void const *b) > { > int *t1=(int *) a; > int *t2=(int *) b; > if (x[*t1]>x[*t2]) return 1; > else return -1; > } > > int main() > { > int i,k; > int sum; > while (cin>>n) > { > if (n==0) break; > maxt=0.0; > cin>>len>>v; > for (i=0;i<n;i++) > { > num[i]=i; > cin>>direct[i]>>x[i]>>str[i]; > if (direct[i]=='p') > t=(len-x[i])/v; > else > t=x[i]/v; > if (t>maxt) > { > maxt=t; > maxi=i; > } > } > num[0]=n-1; > num[n-1]=0; > qsort(num,n,sizeof(num[0]),cmp); > if (direct[maxi]=='p') > { > k=n-1; > sum=0; > while (num[k]!=maxi) > { > if (direct[num[k]]=='n') sum++; > k--; > } > maxi=num[k+sum]; > } > else > { > k=0; > sum=0; > while (num[k]!=maxi) > { > if (direct[num[k]]=='p') sum++; > k++; > } > maxi=num[k-sum]; > } > > printf("%13.2lf %s\n",maxt,str[maxi]); > } > return 0; > } > > > > Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator