Uber 店面

电面,三哥,应该是被整了。

Suppose you have a multiplication table that is N by N. That is, a 2D array where the value at the i-th row and j-th column is (i + 1) * (j + 1) (if 0-indexed) or i * j (if 1-indexed).

Given integers N and X, write a function that returns the k-th smallest element in a N by N multiplication table. Also, take duplicate into account.

Eg. In below matrix of 5X5, 6th smallest number is 4. Its also 7th and 8th smallest number.

   1   2   3   4   5  
   2   4   6   8  10  
   3   6   9  12  15  
   4   8  12  16  20  
   5  10  15  20  25 

还有这题我现在也不知道怎么做。求大神助攻。。。
给2个array,一个是股票当前的价格Si,一个是未来的售价Pi(不用考虑时间因素)。给定你有的本金M。再给一个array限制每个股票最多可以买的数量。 求最大收益。
应该是个dp题。。。求解。。。

如果没理解错的话,是不是可以直接greedy买最大收益的股票的最大数量,然后买次大收益的股票的最大数量。。 …

我是这么写的但是应该不对。比如你有10元。A股卖6块,未来卖8块。B股卖5块,未来卖6.5块。那么最佳策略是买2股B而不是买1股A

知道怎么解了,用dp
存 有x元时的最大收入 依次递归

谢谢提醒。那这题是个二维dp一个维度i是从0到M元的最大收入,另外一个维周是i时买卖股票的数
量。

嗯。另一个维度要存还可以买的数量,因为每个股票有最高限制。赞!~