cswork / OA打开练习工作台

CiscoOA #14

Count Numbers with Digit Sum

估计简单可在线判题

考点(AI 标注)位运算模拟/实现

Count the integers in 1..X whose decimal digit sum is exactly Y. The original requires outputting −1, not 0, when no number qualifies.

输入格式

The input is X Y. The original gave no numeric bounds; this site adds 1≤X≤10^18 and 1≤Y≤162; only positive integers are counted.

输出格式

Output a single integer, the answer.

样例 1

输入:

20 5

输出:

2

样例 2

输入:

1 2

输出:

-1

样例 3

输入:

10 1

输出:

2

样例说明

The outputs of the three public examples are, in order: 2; -1; 2. Verified by independent enumeration or direct simulation.