我越来越好奇这个问题了。。
你可以从集合 P = {1, 2, 3, .. n} 中选择一个子集有多少种方法?子集 S 应满足以下条件:
当你选择 x (x ∈ P, x 是集合 P 的一个元素) 来创建 S 时,你不能为 S 选择 a * x 和 b * x。
约束:
1 <= n <= 1000
2 <= a < b <= n
b % a != 0 ( b is not divisible by a)
例子 :
n = 3 , a = 2, b = 3
so total subsets are 5 ,i.e, {}, {1}, {2}, {3}, {2, 3}
as if in a particular subset there is 1 so 1*2 = 2 and 1*3 cant be there.
so {1,2}, {1,3} and {1,2,3} can't be there