编程介的小学生 2017-11-16 12:24 采纳率: 20.5%
浏览 376
已结题

A Game in the Hospital

Problem Description
Mzry1992 got sick recently. He had to go to the hospital for treatment. The time in the hospital was very boring, so Mzry1992 designed a game and wanted to persuade the nurse to play with him.
The game is played as follows: There are n piles of candies on the table. Each pile has a certain number of candies. Mzry1992 and the nurse take turns to eat candies. As the designed of the game, Mzry1992 always starts first. When it's someone's turn to eat candies, he must select a pile of candies (suppose the pile has m candies now), and eat x(0 < x <= ) candies. Otherwise, he loses the game.
("" indicates the largest integer which is not greater than x)
The nurse loved candies, so she agreed to play with Mzry1992. To start the game, they began to prepare n candy piles. After they had arranged the first n-1 piles of candies (where the number of candies in the ith pile was xi, 1 <= i <= n - 1), a new patient came in and the nurse had to go to take care of him. So Mzry1992 was left alone to decide the number of candies in the last pile.
But before the nurse left, she demanded that the last pile must have no less than L candies and no more than R candies, i.e. , L <= xn <= R.
Mzry1992 agreed with the nurse's demand, since it would be unfair for the nurse if Mzry1992 could place any number of candies in the last pile. Now Mzry1992 wondered, if both he and the nurse play with their best strategies, how many different ways of placing candies in the last pile will make him lose?

Input
The first line has a number T (T <= 20) , indicating the number of test cases.
Then there comes the input of each test case.
The input of each test case has four lines.
The first line contains three integers A, B, and C(0 <= A,B <= 1018, 1 <= C <= 1018), which are defined above in the description.
The second line contains an integer n(1 <= n <= 10), indicating the number of candy piles.
The third line contains n - 1 integers x1, x2, ... , xn-1, where xi(1 <= xi <= 1018) indicates the number of candies in the ith pile.
The fourth line contains two integers L and R(1 <= L <= R <= 1018), which constrains the number of the nth pile in the range [L, R], i.e., L <= xn <= R.
We can guaranteed that at any time will no more than 105.

Output
For every case, you should output "Case #t: " at first, without quotes. The t is the case number starting from 1.
Then follows the answer. which indicates the number of different ways of placing candies in the nth pile that will make Mzry1992 lose.

Sample Input
1
1 2 3
3
3 4
1 8

Sample Output
Case #1: 1

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 mmocr的训练错误,结果全为0
    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀