Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int t;
- int main()
- {
- int p=1;
- int a,b,c;
- cin>>t;
- for(int i=1;i<=t;i++)
- {
- c=0;
- cin>>a>>b;
- if(a==0) cout<<b<<endl;
- else if(b==0) cout<<a<<endl;
- else if(a==0 && b==0) cout<<"0"<<endl;
- else if(a==b) cout<<a<<endl;
- else if(a>b && a%b==0) cout<<a<<endl;
- else if(a<b && b%a==0) cout<<b<<endl;
- else
- {
- if(a<b && b%a!=0)
- {
- c=b;
- while(c%a!=0)
- {
- c=b*p;
- p++;
- }
- cout<<c<<endl;
- }
- if(a>b && a%b!=0)
- {
- c=a;
- while(c%b!=0)
- {
- c=a*p;
- p++;
- }
- cout<<c<<endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement