当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5235:Door game

题目描述
CodeFamer is developing a game which is called Door Game(DG). In this game, player is expected to open some doors to win the game. There is a problem on each door, if player can give correct answer to the problem then the door will open. In a certain door, there are two integers n and k. There are some words on the door, it says:

$F\left( n \right) = \left\{ \begin{array}{l}
n{\kern 1pt} {\kern 1pt} {\kern 1pt} {\kern 1pt} {\kern 1pt} if{\kern 1pt} {\kern 1pt} {\kern 1pt} n < = 1\\
F\left( {n - 1} \right) + F\left( {n - 2} \right){\kern 1pt} {\kern 1pt} {\kern 1pt} {\kern 1pt} {\kern 1pt} otherwise
\end{array} \right.,S\left( n \right) = \sum\limits_{i = 0}^n {DS(F(i)\% F(k))} $ .

DS(x) means the digit sum of x. For example DS(0)=0,DS(1)=1,DS(10254)=1+0+2+5+4=12. If you can calculate S(n), the door will open, then you can advance to the next door.

In order to check play’s answer, CodeFamer should write a program to generate the right answer. However he is busy in designing the UI, so he wants you to help him to write the program.

Here is your task, when given certain n and k, you should calculate S(n).
输入解释
There are multiple test cases. In the first line of the input file there is an integer T indicates the number of test cases.

In the next T lines, each line contains n and k which were mentioned above.

[Technical Specification]

All input items are integers.

1<= T <= 60000

0<=n<=100000000000000 (1e14)

1 <= K <= 1000
输出解释
For each case,the output should occupies exactly one line. The output format is Case #id: ans, here id is the data number starting from 1; ans is the result you are expected to output.

See the sample for more details.
输入样例
2
2 2
3 5
输出样例
Case #1: 0
Case #2: 4
来自杭电HDUOJ的附加信息
Recommend hujie

该题目是Virtual Judge题目,来自 杭电HDUOJ

题目来源 BestCoder Round #42

源链接: HDU-5235

最后修改于 2020-10-25T23:20:56+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
4000/2000MS(Java/Others) 65536/65536K(Java/Others)