Number of ways of distributing K items to N people under given conditions.

Revision en1, by GoWind, 2019-10-29 22:12:22

Recently I got this question in a hiring challenge. I am unable to think of any suitable approach. Please someone help me solve the problem.

"You have an infinite supply of K items (labelled from 1 to K) and an integer N. YOU have to distribute the K items among N people such that the label number of the item received by the ith person is divisible by the label number of the item received by the (i+1)th person or vice-versa.

For example, if the ith person receives an item with the label X and the (i+1)th person receives the item with the label Y, then either X is divisible by Y or Y is divisible by X. Write a program to find the total number of distinct ways of distributing the K items among N people modulo 10^9 + 7."

Constraints:

1<= T <= 100 (T : test cases)

1<= N, K <= 1000

Sample:

N = 2, K = 2, Ans = 4

N = 5, K = 3, Ans = 99

Tags #combinatorics, maths, modular arithmetic

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English GoWind 2019-10-29 22:12:22 957 Initial revision (published)