/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 528.0 KiB
#2 Accepted 5ms 540.0 KiB
#3 Accepted 4ms 796.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
const long long M=2e5+10,MOD=1000000007;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    cin>>t;
    while(t--){
    int a,b;
    cin>>a>>b;
    int gd=__gcd(a,b);
    if(gd==1){
        cout<<-1<<"\n";
        continue;
    }
    for(int i=2;i*i<=gd;i++){
          if(gd%i==0){
           gd=i;
           break;
          }
    }
    cout<<gd<<"\n";

   
     
     
 }


    
    return 0;
 
}

Information

Submit By
Type
Submission
Problem
P1011 LCD
Language
C++20 (G++ 13.2.0)
Submit At
2024-01-05 16:03:50
Judged At
2024-11-11 03:44:18
Judged By
Score
100
Total Time
5ms
Peak Memory
796.0 KiB