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

求DEBUG

Posted by speedcell4 at 2011-07-19 15:34:25 on Problem 3992
In Reply To:这难道不是水题吗。。。。。。为什么老是wa Posted by:yangyangyang91 at 2011-07-19 14:17:58
#include<iostream>
using namespace std;
int a,b;
void swap(int & a,int & b)
{
    if(a<b)
    {
        a=a^b;
        b=a^b;
        a=a^b;
    }
}
int gcd(int a,int b)
{
    if(a%b==0) return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b)
{
    return a*b/gcd(a,b);
}
int key(int a,int b)
{
    swap(a,b);
    if(a%b==0) return a/b;
    else
    {
        int ans=lcm(a,b);
        return ans*ans/a/b;
    }
}
int main()
{
    while(scanf("%d %d",&a,&b),a||b)
    {
        cout<<key(a,b)<<endl;
    }
    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