Accepted
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