12348 | 2024-12-12 20:43:57 | szil | Villámosztás | cpp17 | Accepted 100/100 | 54ms | 620 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int t; cin >> t;
while (t--) {
ll a, b, k; cin >> a >> b >> k;
if (a>b) swap(a, b);
ll mx = 0;
ll X = a+b+k;
for (ll i = 1; i*i <= X; i++) {
if (X % i == 0) {
if (((i-a)%i+i)%i<=k) mx = max(mx, i);
if (((X/i-a)%(X/i)+X/i)%(X/i)<=k) mx = max(mx, X/i);
}
}
cout<<mx<<"\n";
}
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 1ms | 320 KiB | ||||
subtask2 | 30/30 | ||||||
2 | Accepted | 1ms | 320 KiB | ||||
3 | Accepted | 1ms | 320 KiB | ||||
4 | Accepted | 1ms | 320 KiB | ||||
5 | Accepted | 1ms | 320 KiB | ||||
6 | Accepted | 1ms | 320 KiB | ||||
subtask3 | 70/70 | ||||||
7 | Accepted | 1ms | 320 KiB | ||||
8 | Accepted | 1ms | 320 KiB | ||||
9 | Accepted | 1ms | 320 KiB | ||||
10 | Accepted | 1ms | 320 KiB | ||||
11 | Accepted | 1ms | 320 KiB | ||||
12 | Accepted | 8ms | 620 KiB | ||||
13 | Accepted | 12ms | 508 KiB | ||||
14 | Accepted | 17ms | 320 KiB | ||||
15 | Accepted | 41ms | 320 KiB | ||||
16 | Accepted | 52ms | 320 KiB | ||||
17 | Accepted | 54ms | 508 KiB |