/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 5ms 644.0 KiB
#3 Accepted 5ms 588.0 KiB

Code

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

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  int tt; cin >> tt; while (tt--) {
    int n, m; cin >> n >> m;
    int G = __gcd(n, m);
    int ans = G;
    for (int i = 2; i * i <= G; i++) {
      if (G % i == 0) { ans = i; break; }
    }
    cout << (ans == 1 ? -1 : ans) << '\n';
  }
  return 0;
}

Information

Submit By
Type
Submission
Problem
P1011 LCD
Language
C++17 (G++ 13.2.0)
Submit At
2024-10-03 21:57:45
Judged At
2024-11-11 02:44:17
Judged By
Score
100
Total Time
5ms
Peak Memory
644.0 KiB