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 ioriyagami at 2005-07-27 12:24:47 on Problem 2499
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int n;
	int a,b;
	scanf("%d",&n);int c=0;
	while(n--){
		++c;
        scanf("%d%d",&a,&b);
		int left=0,right=0;
		while(a!=1 || b!=1){
			if(a>b){
				int temp=a/b;
				if(a%b==0)temp--;
				left+=temp;
				a-=temp*b;
			}
			else {
				int temp=b/a;
				if(a%b==0)temp--;
				right+=temp;
				b-=a*temp;
			}
		}
		printf("Scenario #%d:\n%d %d\n\n",c,left,right);
		//cout<<""<<c<<':'<<endl;
		//cout<<left<<' '<<right<<endl<<endl;
	}
}

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