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

TLE------>0s(附代码)

Posted by highspeed at 2010-03-20 22:11:08 on Problem 2499
#include<iostream>
using namespace std;

int main()
{
	int left,right,a,b,n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a,&b);
		left=0;right=0;
		while(!(a==1&&b==1))
		{
			if(a>b)
			{
				int t;
				if(b==1)t=a-b;
				else t=a/b;
				left+=t;
				a-=t*b;
			}
			if(a<b)
			{
				int t;
				if(a==1)t=b-a;
				else t=b/a;
				right+=t;
				b-=t*a;
			}
		}
		printf("Scenario #%d:\n",i);
		printf("%d %d\n\n",left,right);
	}
	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