logo AlgoBeat OnlineJudge
登录 注册

#213613. [GCJ 2008 EMEA SemiFinal] Bus Stops

内存限制:1024 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

In the First City of Mars there are bus stops, all aligned in a straight line of length km. The mayor likes to keeps things simple, so he gave the bus stops numbers from to , and separated adjacent stops by exactly km.

There are also buses in the city. The mayor has to plan the bus schedule and he would like to know in how many ways that can be done. This number can be very large. Luckily there are a few constraints:

  • In the beginning of the day all the buses are in the first bus stops (one bus per stop)
  • Buses only move from the left to the right ( is the leftmost bus stop)
  • At the end of the day all the buses must be in the last bus stops (one bus per stop)
  • In each bus station exactly one bus has to stop
  • For the same bus the distance between any two consecutive stops is at most km

Help the mayor evaluate the number of schedules. However try not to give him very bad news (a lot of schedules) so just output the real number modulo .

输入格式

The first line in the input file is the number of cases .

Each of the next lines contains integers separated by one space: , and .

输出格式

For each case output the number of ways to plan the bus schedules (modulo ) in the format "Case #: [number of ways modulo ]" where is the number of the test case, starting from .

样例

样例输入 1

3
10 3 3
5 2 3
40 4 8

样例输出 1

Case #1: 1
Case #2: 3
Case #3: 7380

数据范围与提示

Sample Explanation

Let's name the buses: , , ...

For the first case there is only one possible way of planning the schedule: . . .

For the second case the possible ways of planning are:

  • ,
  • ,
  • .

Limits

Small dataset (8 Pts, Test set 1 - Visible)

Large dataset (26 Pts, Test set 2 - Hidden)