logo AlgoBeat OnlineJudge
登录 注册

#216678. [GKS 2018 #F] Palindromic Sequence

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

题目描述

Hannah is working on a new language which consists only of first lowercase letters of the English alphabet. She is obsessed with palindromes, which are words that read the same forward and backward, e.g hannah and civic. She has written down all of the words in her language of length at most , that are also palindromes.

Now, she is interested in finding the length of the word that is lexicographically smallest among all the words she has written. A word composed of ordered letters , , ..., is lexicographically smaller than word , , ..., if , where i is the first index where characters differ in the two words. Also, a prefix of a word is considered lexicographically smaller than the word itself. For example, the following words are arranged in lexicographically increasing order: a, aa, aba, cabac, d.

输入格式

The first line of the input gives the number of test cases, . test cases follow. Each test case consists of one line containing three integers L, N, and K, as described above.

输出格式

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the length of the lexicographically smallest palindromic word among all palindromic words of length at most in Hannah's language. If no such word exists, output .

样例

样例输入 1

2
2 3 4
2 3 9

样例输出 1

Case #1: 3
Case #2: 0

数据范围与提示

In Sample Cases #1 and #2, Hannah's language consists only of the letters a and b. All the palindromic words of length at most in her language, in lexicographic order, are: , , , , , , and .

In Sample Case #1, the fourth-smallest word is , which is characters long, so we output .

In Sample Case #2, exceeds the total number of possible words, and hence we output .

Limits

.

.

.

Small dataset (Test set 1 - Visible)

.

Large dataset (Test set 2 - Hidden)

.