查看题目 登录后递交 讨论 题解 文件 统计 ID 2760 时间 4000ms 内存 1024MiB 难度 (无) 标签 brute force greedy math number theory *2200 递交数 0 已通过 0 上传者 root
首先计算一下前两个数的GCD,有2种可能: 1:如果GCD(x1,x2) == d,那就没必要再计算GCD(xi,xj) (1 < i < j <= n)了,只要计算一下LCM(x1,x2)即可,因为如果GCD(xi,xj) == d,LCM(xi,xj)肯定大于LCM(x1,x2);如果GCD(xi,xj) == d_ > d,LCM(xi,xj)有可能小于LCM(x1,x2),不过这个等...
You are given an arrayaconsisting of integersa1,a2,…,a**n Your problem is to find such pair of indicesi,jthatlcm(aiai,ajaj)is minimum possible. lcm(x,y) is the least common multiple of andxandy(minimum positive number such that bothxandyare divisors of this number). Input The first ...
G. Minimum Possible LCM 题意:求 个数中最小公倍数数值最小的两个数的下标。 如果 是 的最大公因数,那么 一定小于 ,剩下亦是如此; 如果 不是 的最大公因数,那么 也一定小于 ,如果 是 的最大公因数,同样 所以综上所述,只需要枚举最大公因数 ,然后取包含前两项的 并且最后取 即可。 代码 #include<...