logo AlgoBeat OnlineJudge
登录 注册

#213588. [GCJ 2008 #1B] Number Sets

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

题目描述

You start with a sequence of consecutive integers. You want to group them into sets.

You are given the interval, and an integer . Initially, each number in the interval is in its own set.

Then you consider each pair of integers in the interval. If the two integers share a prime factor which is at least , then you merge the two sets to which the two integers belong.

How many different sets there will be at the end of this process?

输入格式

One line containing an integer , the number of test cases in the input file.

For each test case, there will be one line containing three single-space-separated integers , , and . and are the first and last integers in the interval, and is the number as described above.

输出格式

For each test case, output one line containing the string "Case #: " where is the number of the test case, starting from 1, and is the number of sets.

样例

样例输入 1

2
10 20 5
10 20 3

样例输出 1

Case #1: 9
Case #2: 7

数据范围与提示

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

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