logo AlgoBeat OnlineJudge
登录 注册

#216644. [GKS 2017 #E] Copy & Paste

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

题目描述

You want to create a certain target string , which consists only of lowercase English letters. You start with an empty string, and you are allowed to perform the following operations:

  • Add any single lowercase letter to the end of your string.
  • Copy any substring of your string (that is, all of the characters between some start point in your string and some end point in your string) to the clipboard. Doing this overwrites whatever was in the clipboard before. The clipboard starts off empty.
  • Add the entire contents of the clipboard to the end of your string. (The contents of the clipboard do not change.)

What is the smallest number of operations needed to create your target string? Note that you must create exactly the target string, with no additional letters.

输入格式

The first line of the input gives the number of test cases, . lines follow. Each line contains the target string .

输出格式

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 minimum number of operations (as described in the problem statement) needed to create the target string.

样例

样例输入 1

3
abcabab
aaaaaaaaaaa
vnsdmvnsnsdmkvdmkvnsdmk

样例输出 1

Case #1: 6
Case #2: 7
Case #3: 15

数据范围与提示

The optimal solution for Sample Case You can't use 'macro parameter character #' in math mode#1 is:

  1. Type .
  2. Type .
  3. Type .
  4. Copy to the clipboard.
  5. Paste at the end of the string.
  6. Paste at the end of the string.

The optimal solution for Sample Case You can't use 'macro parameter character #' in math mode#2 is:

  1. Type .
  2. Type .
  3. Type .
  4. Copy to the clipboard.
  5. Paste at the end of the string.
  6. Copy to the clipboard.
  7. Paste at the end of the string.

Limits

consists only of lowercase English letters in the range a through z.

Small dataset (Test set 1 - Visible)

.

length of .

Large dataset (Test set 2 - Hidden)

.

length of .