Interesting Problem
Description
Dearway knows some people like math problems but other not. Now the fact is in front of you all.
Give n integers x1 x2 ... xn, you should count how many integers from 1 to m that can be divided by at least one of them.
Input
The first line is an integer T which shows the number of cases.
Then T cases follow. Each case contains 2 lines:
The first line has 2 integers n and m.
The second line contains n integers.
(0 < n < 11, 0 < m < 2^31, 0 < xi < 100)
Output
For each case print the answer in a single line.
Sample Input
2
1 10
3
2 20
3 5
Sample Output
3
9
Source
题意是给出n个数an,询问1到m至少可以被其中一个数整除的个数
利用容斥原理解,用二进制或DFS确定项
aUbUc...Uz=a+b+c+..+z-anb-anc-......
a=m/ai
anb=lcm(a,b),anbnc..nz=lcm(a,b,c...z)