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 lisanwan at 2008-12-11 20:56:43 on Problem 1922
//这是第一份代码,wa!!!
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int n;
	double a,b,t,min;
	while(1)
	{
		cin>>n;
		if(n == 0)
			break;
		min=0.0;
		for(int i = 0; i != n; i++)
		{
			cin>>a>>b;
			if(b < 0) continue;
			t = ceil(4.5*(double)3600/a + b);
			if(i == 0) min = t;
			else if(min > t) min = t;
		}
		cout<<(int)min<<endl;
	}
	return 0;
}

//这是第二份,ac!!!!
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int n,a,b;
	double t,min;
	while(1)
	{
		cin>>n;
		if(n == 0)
			break;
		min=1e18;
		for(int i = 0; i < n; i++)
		{
			cin>>a>>b;
			if(b >= 0)
			{
				t = ceil(4.5*(double)3600/(double)a + (double)b);
			    if(t < min) 
					min = t;
			}
		}
		cout<<(int)min<<endl;
	}
	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