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
相关推荐
Escalating_xu7 小时前
【Linux】进程信号:从产生、阻塞与递达到 sigaction、可重入与内核返回路径吃着火锅x唱着歌9 小时前
LeetCode 3597.分割字符串.道阻且长.1 天前
8.LeetCode算法习题讲解--滑动窗口--长度最小的子数组测试19981 天前
Python接口测试之requests库安装和导入浅念-1 天前
MySQL 索引底层完整详解|磁盘Page|B+树推导|聚簇非聚簇索引|索引SQL操作我命由我123451 天前
商圈六大配套Dr.kangder1 天前
嵌入式面试总结(二十二)——指针Dr.kangder1 天前
嵌入式面试总结(二十)——ISA原理Nil2081 天前
leetcode 48旋转图像Dr.kangder1 天前
嵌入式面试总结(二十一)——C语言关键字