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

Re:好吧,我学得不好,实在搞不懂。。。

Posted by PKU10617243 at 2009-10-10 14:35:55 on Problem 1922
In Reply To:好吧,我学得不好,实在搞不懂。。。 Posted by:lisanwan at 2008-12-11 20:56:43
你第一份代码的问题是逻辑问题   if(i == 0)和前面的continue有冲突

4
25	-155
20	0
27	190
30	240

这个数据你都通不过,你的答案是0,不wa才怪!

> //这是第一份代码,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