cswork / OA打开练习工作台

BNY MellonOA #3

Digit Sum

估计困难评测数据准备中,可先阅读题面

考点(AI 标注)树形博弈位运算

There is a lottery with c coupons and p participants. Each participant picks exactly one coupon. Coupons are numbered from lowLimit to highLimit, inclusive. The winner of the lottery is any participant who owns a coupon with the sum of digits s written on it. If there is more than one winner, then the prize is split equally among them.

  • Determine s in such a way that there is at least one winner, and the prize is split among the most participants.
  • Also determine how many ways the required sum s can be chosen, so that the lottery is split among the maximum number of participants. Function Description Complete the function waysToChooseSum in the editor below. The function must return an array of long integers with 2 elements:
  • The total number of ways to choose sum so that maximum possible participants win the lottery.
  • The number of participants who will win the lottery. waysToChooseSum has the following parameter(s):
  • long lowLimit: a long integer, the starting number of the lottery coupons
  • long highLimit: a long integer, the ending number of the lottery coupons

Constraints

  • 1 ≤ lowLimit < highLimit ≤ 10¹⁸