def gcd(a,b):
while b:
a,b=b,a%b
return a
def init_divisors(a,b):
d=gcd(a,b)
i=1
while i*i<=d:
if d%i==0:
ans.append(i)
if i!=d//i:ans.append(d//i)
i+=1
ans.sort()
a,b=map(int,input().split())
ans=\[\]
init_divisors(a,b)
q=int(input())
for _ in range(q):
L,R=map(int,input().split())
l=0;r=len(ans)-1
while (l<r):
mid=l+r+1>>1
if ansmid<=R:l=mid
else: r=mid-1
if ansr>=L:
print(ansr)
else:
print("-1")
蓝桥杯刷题--python-36
芝士小熊饼干2024-04-07 16:04
相关推荐
IT龟苓膏34 分钟前
并发深度解析】硬核手撕 ForkJoinPool + WorkStealing + CompletableFuture 底层源码与大厂面试演练心软小念6 小时前
2026软件测试高频面试题洛水水1 天前
【力扣100题】86.柱状图中最大的矩形洛水水1 天前
【力扣100题】85.每日温度海绵宝宝的月光宝盒1 天前
6-机械设计基础物理知识_日拱一卒1 天前
LeetCode:22括号生成枫子有风1 天前
LLM-RAG(大厂面试常问问题)洛水水1 天前
【力扣100题】84.字符串解码嵌入式ZYXC1 天前
第9篇:《面试题:ADC前端为什么要加运放跟随器?什么情况下可以不加?》洛水水1 天前
【力扣100题】90.寻找重复数