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

Re:哪位大虾帮我看看哪里错了,先谢谢了

Posted by zhao0057 at 2006-08-24 21:19:49 on Problem 2142
In Reply To:哪位大虾帮我看看哪里错了,先谢谢了 Posted by:Cell at 2005-01-05 15:29:19
```第三行
> 我是看不出来了，虽然效率会比较差，但我觉得逻辑好像没问题阿
> sample也都没有问题
> #include "stdio.h"
> void f(const int &a,const int &b,const int &d,int &x,int &y)
> {
> 	x=1;y=0;/////此处x应为0
> 	while (1)
> 	{
> 		if (a*x<b*y+d)
> 		{
> 			if (y==0&&(d-a*x)%b==0)
> 			{
> 				y=(d-a*x)/b;
> 				break;
> 			}
> 			++x;
> 			continue;
> 		}
> 		if (a*x==b*y+d)
> 			break;
> 		else
> 			++y;
> 	}
> }
> void main()
> {
> 	int a,b,d,ax,bx,ay,by;
> 	while (scanf("%d %d %d",&a,&b,&d))
> 	{
> 		if (a==0&&b==0&&d==0)break;
> 		f(a,b,d,ax,bx);
> 		f(b,a,d,by,ay);
> 		if (ax+bx<ay+by||((ax+bx==ay+by)&&a*ax+b*bx<a*ay+b*by))
> 			printf("%d %d\n",ax,bx);
> 		else
> 			printf("%d %d\n",ay,by);
> 	}
> }
```

Followed by: