Codeforces 1008D Pave the Parallelepiped 思维+组合数

D. Pave the Parallelepiped
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a rectangular parallelepiped with sides of positive integer lengths AABB and CC.

Find the number of different groups of three integers (aabbcc) such that 1abc1≤a≤b≤c and parallelepiped A×B×CA×B×C can be paved with parallelepipeds a×b×ca×b×c. Note, that all small parallelepipeds have to be rotated in the same direction.

For example, parallelepiped 1×5×61×5×6 can be divided into parallelepipeds 1×3×51×3×5, but can not be divided into parallelepipeds 1×2×31×2×3.

Input

The first line contains a single integer tt (1t1051≤t≤105) — the number of test cases.

Each of the next tt lines contains three integers AABB and CC (1A,B,C1051≤A,B,C≤105) — the sizes of the parallelepiped.

Output

For each test case, print the number of different groups of three points that satisfy all given conditions.

Example
input
Copy
4
1 1 1
1 6 1
2 2 2
100 100 100
output
Copy
1
4
4
165
Note

In the first test case, rectangular parallelepiped (1,1,1)(1,1,1) can be only divided into rectangular parallelepiped with sizes (1,1,1)(1,1,1).

In the second test case, rectangular parallelepiped (1,6,1)(1,6,1) can be divided into rectangular parallelepipeds with sizes (1,1,1)(1,1,1)(1,1,2)(1,1,2)(1,1,3)(1,1,3) and (1,1,6)(1,1,6).

In the third test case, rectangular parallelepiped (2,2,2)(2,2,2) can be divided into rectangular parallelepipeds with sizes (1,1,1)(1,1,1)(1,1,2)(1,1,2)(1,2,2)(1,2,2) and (2,2,2)(2,2,2).


从所有的因数里,通过组合数学和容斥原理的方法,当然也可以求出正确的结果,但这是大佬的操作,不是我弱鸡小叮当的操作。但如果反过来,首先就把所有的因数都分好类,然后以类为基础做组合数,就简单多了。所有的类一共有7种,要么只属于A,要么只属于B,要么只属于C,要么只属于AB,要么只属于BC,等等。我们知道,几个数的公约数的个数,也是他们最大公约数的因数个数,这就很好算了。接下来我们枚举三个数的类别,当三个类别涵盖了a,b,c三个数的时候,我们就能用来枚举,反之就不行。然后我们枚举的时候在记录一下从每一类里面要取几个数出来。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值