Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int t;
  4. int main()
  5. {
  6.     int p=1;
  7.     int a,b,c;
  8.     cin>>t;
  9.     for(int i=1;i<=t;i++)
  10.     {
  11.        c=0;
  12.        cin>>a>>b;
  13.        if(a==0) cout<<b<<endl;
  14.        else if(b==0) cout<<a<<endl;
  15.        else if(a==0 && b==0) cout<<"0"<<endl;
  16.        else if(a==b) cout<<a<<endl;
  17.        else if(a>b && a%b==0) cout<<a<<endl;
  18.        else if(a<b && b%a==0) cout<<b<<endl;
  19.        else
  20.        {
  21.            if(a<b && b%a!=0)
  22.            {
  23.               c=b;
  24.               while(c%a!=0)
  25.               {
  26.                   c=b*p;
  27.                   p++;
  28.               }
  29.               cout<<c<<endl;
  30.            }
  31.            if(a>b && a%b!=0)
  32.            {
  33.               c=a;
  34.               while(c%b!=0)
  35.               {
  36.                   c=a*p;
  37.                   p++;
  38.               }
  39.               cout<<c<<endl;
  40.            }
  41.  
  42.        }
  43.     }
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement