Please tell me what mistake i am doing

#include
#include
using namespace std;

int gcd(int a, int b)
{
if(b==0)
return a;
return gcd(b, a%b);
}
int main() {
int t;
cin>>t;
while(t–)
{
int A,B,gcd_value,lcm_value;
cin>>A>>B;
gcd_value=gcd(A,B);
lcm_value=((A*B)/gcd_value);
cout<<gcd_value<<" "<<lcm_value<<endl;
}
return 0;
}

You forgot to write <iostream> on the top with #include
Like this, #include <iostream>

you are not written and<stdio.h>

weeps

Try this test case:

Input

1
999983 999979

PS: Format your code, by pasting it in between a pair of 3 backticks (`). Otherwise, comments like this or like this are not uncommon.

2 Likes

you forgot to include header files in your code

if no is divisible by 3 you need to add the digit of its decimal.if no is divisible by 11 .split its decimal notation

Try this input:

1
987654 987654

For convenience and readability, it’s best to give a link to a codechef submission

and/or

use three backticks on a line either side of code:

#include <iostream>
#include <algorithm>
using namespace std;

int gcd(int a, int b)
{
    if(b==0)
     return a;
    return gcd(b, a%b);
}
int main() {
	int t;
	cin>>t;
	while(t--)
	{
	    int A,B,gcd_value,lcm_value;
	    cin>>A>>B;
	    gcd_value=gcd(A,B);
	    lcm_value=((A*B)/gcd_value);
	    cout<<gcd_value<<" "<<lcm_value<<endl;
	}
	return 0;
}
1 Like