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

对二叉树有了点理解 贴个代码

Posted by 154115081034 at 2016-04-14 23:55:09 on Problem 2499
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 11000

int main()
{
    int T, m, n, l, r, cnt=1;
    scanf("%d", &T);

    while(T--)
    {
        l=r=0;
        scanf("%d%d", &m, &n);
        while(1)
        {
            if(m==1 && n==1)
                break;
            if(m<n)
            {
                if(n%m==0)
                {
                    r+=n/m-1;
                    n=1;
                }
                else
                {
                    r+=n/m;
                    n=n%m;
                }
            }
            if(m>n)
            {
                if(m%n==0)
                {
                    l+=m/n-1;
                    m=1;
                }
                else
                {
                    l+=m/n;
                    m=m%n;
                }
            }
        }
        printf("Scenario #%d:\n", cnt++);
        printf("%d %d\n\n", l, r);
    }
    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