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:麻烦各位ac了的同学,给出你们的测试数据可以吗?我的测试都过了,就是wa,谢谢了

Posted by scauben0 at 2005-09-14 19:00:09 on Problem 2614
In Reply To:麻烦各位ac了的同学,给出你们的测试数据可以吗?我的测试都过了,就是wa,谢谢了 Posted by:scauben0 at 2005-09-14 18:48:29
#include<stdio.h>
void main()
{
	unsigned long l;
	int a[102];
	int b[102];
	int i,j,m,n;
	freopen("1.txt","r",stdin);
	scanf("%ld%d",&l,&n);
    if(l>20250){printf("0\n");return;}
    l=l*1000;
	for(i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
	}

	int min=-1;
	int c,d;
	for(i=1;i<=n;i++)
	{m=l/a[i];
	 n=l%a[i];
          c=m*(b[i]-a[i]);
	 if(c>=n) {min=0;break;}
	 else
	 {if((n-c)<min||min==-1)
	 min=n-c;
	 }
    }
    
	printf("%d",min);
}
和前面那个同学的想法差不多,只是把剩余的空间加起来和剩下的酒比较,如果大于就输出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