Home > Back-end >  2020 for small beautiful array to solve Meituan programming
2020 for small beautiful array to solve Meituan programming

Time:10-05

title: the length of an array of n, the scope of the number of each array between L and R, and all the elements in the array and for multiple of k, meet the requirements of the array number how many? The final result you just need to return to mold 1 + 7 e9

N=9, for example, L=1, R=3, k=1, a total of 19683 this array,
I am not mature idea:
And the range is [L, n * n * R], for a certain number of them I meet the above requirements, then I % k=0, and for a number of arrays of dp [I] I, then the next meet the requirements and is the I + k,
So dp [I] + k=dp [I] * handle (k, n), handle function is that a ball on the n k box, each box at least zero, most put R number minus the box as the original, but the permutation and combination of knowledge have been returned to the PE teacher, do not know to have bosses can provide the train of thought, or there are other better ways to solve this problem!!!!!!
thank you

CodePudding user response:

Don't understand ah, if can be a decimal number, not thousands?

CodePudding user response:

Forgot to say scope: 1 & lt;=n<=1 e5, 1 & lt;=k<=10, 1 & lt;=L<=R<=1 e9

CodePudding user response:

I won't be this yesterday to the first,,,
Is this my train of thought
R - L when k=1 + 1=3 so the number nine list can only in [1, 2, 3] pick
The minimum value of 1 * 9=9 then 9% 1=0 is satisfy multiple of k
A maximum of 9 * 3=27 27% 1=0 also meet
So the total is 3 * * 9=19683 ways (9 each location can choose three)
But when k> 1 I didn't want to border situation when
Need to consider: (n) % k * L! R)=0 (n * % k!=0 when the boundary does not meet to move again after several places except k
  • Related