Accepted
Code
#include <vector>
#include <numeric>
#include <iostream>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int tt;
cin >> tt;
while (tt--) {
int n, m;
cin >> n >> m;
n = gcd(n, m);
if (n == 1) {
cout << -1 << '\n';
} else {
m = n;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
m = i;
break;
}
}
cout << m << '\n';
}
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1011 LCD
- Language
- C++20 (G++ 13.2.0)
- Submit At
- 2024-05-06 21:33:23
- Judged At
- 2024-11-11 03:31:26
- Judged By
- Score
- 100
- Total Time
- 5ms
- Peak Memory
- 592.0 KiB