#P1125. [NOIP 2008 提高组] 笨小猴

    ID: 125 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>2008NOIp 提高组排序素数判断,质数,筛法

[NOIP 2008 提高组] 笨小猴

Description

The silly little monkey has a very small vocabulary, so he always struggles with English multiple-choice questions. But he found a method, and experiments show that using this method greatly increases the chance of choosing the correct option.

The method is described as follows: suppose maxn \text{maxn} is the number of occurrences of the most frequent letter in a word, and minn \text{minn} is the number of occurrences of the least frequent letter in the word. If maxnminn \text{maxn}-\text{minn} is a prime number, then the silly little monkey considers this a Lucky Word. Such a word is very likely to be the correct answer.

Input Format

A single word containing only lowercase letters, with length less than 100100.

Output Format

Two lines in total. The first line is a string: if the input word is a Lucky Word, output Lucky Word; otherwise, output No Answer.

The second line is an integer: if the input word is a Lucky Word, output the value of maxnminn \text{maxn}-\text{minn} ; otherwise, output 00.

error
Lucky Word
2
olympic
No Answer
0

Hint

[Explanation for Sample Input/Output 1]

In the word error, the most frequent letter r \texttt{r} appears 33 times, and the least frequent letter appears 11 time. 31=23-1=2, and 22 is a prime number.

[Explanation for Sample Input/Output 2]

In the word olympic, the most frequent letter i \texttt{i} appears 11 time, and the least frequent letter appears 11 time. 11=01-1=0, and 00 is not a prime number.

(The original error in this part has been corrected.)

NOIP 2008 Senior, Problem 1.

Translated by ChatGPT 5