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

WA的有点郁闷。。。大家能帮我看看吗?

Posted by sgxiao at 2008-08-31 17:57:43 on Problem 2499
/*
Author: sgxiao
Title: 2499 -- Binary Tree
LANG: C
Date : Sun Aug 31 17:12:54 CST 2008
*/

#include<stdio.h>

#define TYPE unsigned long long int
/* #define TYPE int */

TYPE l, r;

void node(TYPE i, TYPE j)
{
	if( i == j ) return;	
	if( i == 0 || j == 0) return ;
	if( i == 1 || j == 1 ) {
		l += i - 1;
		r += j - 1;
		return;
	}

	if( i > j ) {

		l += (TYPE)(i/j);
		node(i%j, j);
	} else {
		r += (TYPE)(j/i);
		node(i, j%i);
	}
}




int main(void)
{
	TYPE i, j;
	int k;
	int n;
	scanf("%d", &n);
	
	for(k = 1; k <= n; k++) {
		scanf("%llu%llu", &i, &j);
		node(i, j);
		printf("Scenario #%d:\n", k);
		printf("%llu %llu\n\n", l, r);
		l = 0;
		r = 0;
	} 

	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