7152: Substring Characters 分享至QQ空间

Time Limit(Common/Java):1000MS/3000MS     Memory Limit:65536KByte
Total Submit: 2            Accepted:2

Description

The set of distinct characters in a string is referred to as the generalized period of the string. As an example, the generalized period of the string “aabbabb” is {‘a’,‘b’}

A proper substring is a contiguous substring that is contained in a string and is not the string itself. So “aabbabb” is not a proper substring of the above example.

A minimal proper substring is one that can have no character removed from either end and still have the same generalized period. “aabb” is a proper substring of the example, but it is not minimal. “ab” is minimal.

Unique means that multiple occurrences of the same minimal proper substring in a string are only to be counted once. In the example, “ab” appears twice, but is counted once—hence the number of proper minimal unique substrings with the same generalized period of the entire string is two: “ab” and “ba”.

Your team is to write a program to count the number of proper minimal unique substrings of a given string that have the same generalized period as the string itself.


Input

Input to your program is a series of lines terminated by end-of-file. Each line is a test case consisting of alphanumeric characters (a–z, A–Z, 0–9). Upper-case and lower-case letters are distinct. The new line character is not part of the test case string. No test case string will exceed 80 characters. There will be at most 100 test strings in input.

Output

For each input line print a line containing the number of proper minimal unique substrings of the input string with no leading or trailing whitespace and no extra leading signs or zeros.

Sample Input

Sample Output

Source

2020 North Central NA Regional Contest

Uploader

crq


[Submit] [Status]

|Back |   | Top|
Copyright @ 2008-2022(浙ICP备2022001332号), TZOJ. All Rights Reserved.