We have n random numbers which is less than 1.0 and greater than 0 i.e. 0.0 < a_i < 1.0 .
How to check whether there exist a set S which contains elements of property a_i such that summation of all a_i is equal to a integer constant K where i=1,2,...,n ?
Note: set should contain n elements.
e.g.
- N = 4 and K = 2 then we can choose {0.5 ,0.5 ,0.5 ,0.5} or {0.25 ,0.75 ,0.5 ,0.5} since their sum is 2 so answer is yes .
- N = 4 and K = 4 then answer is no since we can't choose a_i such that their sum K = 4 .
Aucun commentaire:
Enregistrer un commentaire