6 solutions

  • 0
    @ 2025-10-13 18:16:44
    #include<bits/stdc++.h>
    using namespace std;
    //gcd(a,b)=gcd(b,a%b)
    /*
    18 32
    32 18
    18 14
    14 4
    4 2
    2 0
    */
    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;
    		cin>>a>>b;
    		cout<<gcd(a,b)<<endl;
    	}
    	return 0;
    }
    
    

    Information

    ID
    176
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    1
    Tags
    # Submissions
    72
    Accepted
    24
    Uploaded By