My issue
include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
while(t–){
int x,y;
cin>>x>>y;
if(x%y==0){
cout<<y<<endl;
}
else if(y%x==0){
cout<<x<<endl;
}
else{
if(x%2==0 && y%2==0){
cout<<2<<endl;
}
else{
cout<<1<<endl;
}
}
}
}
I am unable to find error in this code for the respective ques .
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
while(t--){
int x,y;
cin>>x>>y;
if(x%y==0){
cout<<y<<endl;
}
else if(y%x==0){
cout<<x<<endl;
}
else{
if(x%2==0 && y%2==0){
cout<<2<<endl;
}
else{
cout<<1<<endl;
}
}
}
}
Problem Link: Sub or Swp Practice Coding Problem - CodeChef