#H1070. 五元 gcd 与 lcm 求和 II(打表版)
五元 gcd 与 lcm 求和 II(打表版)
题目描述
给定五个正整数 ,求
$$\sum_{d=1}^{D}\sum_{r=1}^{R}\sum_{e=1}^{E}\sum_{a=1}^{A}\sum_{m=1}^{M} \frac{\gcd(d,r)\gcd(d,e)\gcd(d,a)\gcd(d,m)\gcd(r,e)\gcd(r,a)\gcd(r,m)\gcd(e,a)\gcd(e,m)\gcd(a,m)} {\gcd\big(\operatorname{lcm}(d,r),\operatorname{lcm}(d,e),\operatorname{lcm}(d,a),\operatorname{lcm}(d,m),\operatorname{lcm}(r,e),\operatorname{lcm}(r,a),\operatorname{lcm}(r,m),\operatorname{lcm}(e,a),\operatorname{lcm}(e,m),\operatorname{lcm}(a,m)\big)^{3}\cdot \gcd\big(\operatorname{lcm}(d,r,e),\operatorname{lcm}(d,r,a),\operatorname{lcm}(d,r,m),\operatorname{lcm}(d,e,a),\operatorname{lcm}(d,e,m),\operatorname{lcm}(d,a,m),\operatorname{lcm}(r,e,a),\operatorname{lcm}(r,e,m),\operatorname{lcm}(r,a,m),\operatorname{lcm}(e,a,m)\big)}$$其中 为最大公约数, 为最小公倍数,$\operatorname{lcm}(x,y,z)=\operatorname{lcm}(\operatorname{lcm}(x,y),z)$。
答案对 取模。
输入格式
第一行一个正整数 ,表示数据组数。
接下来 行,每行五个正整数 。
输出格式
输出 行,每行一个整数表示对应数据组的答案。
样例
样例输入 #1
2
1 1 1 1 1
12 15 18 20 25
样例输出 #1
1
285844430
数据规模与约定
- ;
- ;
- 保证同一组数据中所有 之和不超过 。
逐个五元组枚举并维护分子、分母的做法可以通过;若把每对数、每个三元组的最小公倍数预先打表,可以更快。
本题每个数据组的答案都是整数。