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

建议使用的浏览器:

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

2848:Number Cutting Game

题目描述
Two boys boyA and boyB are playing a simple game called Number Cutting Game. Now I will introduce it to you, my friend.

At the beginning of the game, a machine will generate two numbers, N(10 < N < 10 ^ 19) and K(2 <= K <= length(N)). Then boyA and boyB are take turns to play it:

When one player receives two numbers N and K, his task is to cut N into K nonempty pieces. If length(N) < K, that is to say he can not able to cut, he loses the game. Otherwise, he adds these K pieces together and get the sum SUM. Then let N = SUM and throw N and K to another player.

We assume boyA receives the two numbers from the machine firstly and they are smart enough to choose the best strategy for himself.
Now please help boyA to calculate weather he can win if he receives N and K firstly.

Here is a sample for you N = 103, K = 2.
Fisrtly, boyA receives N = 103, K = 2. He has two ways to cut like: 1|03 => 1 + 03 = 4, or 10|3 => 10 + 3 = 13.
Then, boyB receives from boyA. If boyB receives N = 4, K = 2, he loses the game. If boyB receives N = 13 and K = 2, he has only one way to cut: 1|3 = 1 + 3 = 4, then he will win the game.
So you can see boyA will win if he choose the best strategy.
输入解释
No more than 1000 cases. Each contains two line, first line an integer N(10 < N < 10 ^ 19), second line K(2 <= K <= length(N)).
输出解释
If boyA can win, print 1, otherwise 0.
输入样例
103
2
999999999999999999
2
输出样例
1
0
来自杭电HDUOJ的附加信息
Recommend gaojie

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

源链接: HDU-2848

最后修改于 2020-10-25T22:57:28+00:00 由爬虫自动更新

共提交 0

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