11958 | 2024-11-22 12:04:26 | lacito | Villámosztás | pypy3 | Elfogadva 100/100 | 79ms | 21996 KiB |
#!/usr/bin/env python3
# @check-accepted: *
from itertools import product
def primeFactor(n):
res=[]
i=2
while i*i<=n:
cur=0
while n%i==0:
cur+=1
n//=i
if cur!=0:
res.append((i,cur))
i+=1
if n>1:
res+=[(n,1)]
return res
def sol():
a,b,k = map(int, input().strip().split())
primes=primeFactor(a+b+k)
res=1
for A in product(*[range(n+1) for p,n in primes]):
cur=1
for i in range(len(primes)):
cur*=primes[i][0]**A[i]
if cur>res:
i=a//cur
if a <= cur*i <= a+k or a <= cur*(i+1) <= a+k:
res=cur
return res
for t in range(int(input())):
print(sol())
Részfeladat | Összpont | Teszt | Verdikt | Idő | Memória | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Elfogadva | 46ms | 19700 KiB | ||||
subtask2 | 30/30 | ||||||
2 | Elfogadva | 46ms | 19508 KiB | ||||
3 | Elfogadva | 48ms | 19772 KiB | ||||
4 | Elfogadva | 52ms | 21476 KiB | ||||
5 | Elfogadva | 64ms | 21528 KiB | ||||
6 | Elfogadva | 68ms | 21480 KiB | ||||
subtask3 | 70/70 | ||||||
7 | Elfogadva | 46ms | 19508 KiB | ||||
8 | Elfogadva | 48ms | 19772 KiB | ||||
9 | Elfogadva | 52ms | 21476 KiB | ||||
10 | Elfogadva | 64ms | 21528 KiB | ||||
11 | Elfogadva | 68ms | 21480 KiB | ||||
12 | Elfogadva | 74ms | 21772 KiB | ||||
13 | Elfogadva | 70ms | 21920 KiB | ||||
14 | Elfogadva | 68ms | 21772 KiB | ||||
15 | Elfogadva | 71ms | 21972 KiB | ||||
16 | Elfogadva | 72ms | 21728 KiB | ||||
17 | Elfogadva | 79ms | 21996 KiB |