/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 16ms 568.0 KiB
#3 Accepted 50ms 552.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
void solve()
{
    int n,m; cin>>n>>m;
    int a=min(n,m);
    int b=sqrt(a);
    for(int i=2;i<=b;i++)
    {
        if(n%i==0 && m%i==0)
        {
            cout<<i<<endl;
            return;
        }
    }
    if(max(n,m)%a==0 && a!=1) {cout<<a<<endl; return;}
    cout<<-1<<endl;
}
int main()
{
    int t; cin>>t; while(t--) solve();
}

Information

Submit By
Type
Submission
Problem
P1011 LCD
Language
C++17 (G++ 13.2.0)
Submit At
2023-12-02 10:11:09
Judged At
2023-12-27 23:33:00
Judged By
Score
100
Total Time
50ms
Peak Memory
568.0 KiB