Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

结果是截断不是四舍五入

Posted by zhucheng at 2005-10-23 22:21:43 on Problem 2674
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator