GoWind's blog

By GoWind, history, 4 years ago, In English

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

Full text and comments »

  • Vote: I like it
  • -4
  • Vote: I do not like it