Submit | All submissions | Best solutions | Back to list |
MASUMREPORT - Nahid The Reporter |
Nahidul Islam Sayel is a reporter for SIU Daily Journals. One day, while writing an article, he decided to find out the average letter in a given text. There are three steps to find the average letter:
- He counts the number of times each letter repeats in the given portion of the newspaper.
- He adds up all the repeated values and calculates their average.
- He ignores other symbols or digits that are not letters.
The average is always rounded to the nearest whole number. If there is any fraction value 'f', the average will be 'f+1'.
Let's discuss an example: If there is a string "aabbc", where 'a' appears 2 times, 'b' appears 2 times, and 'c' appears 1 time, the total count of letters is (2+2+1) or 5.
The average is 5/3 = 1.67, which is rounded up to 2. This is the average value of letters for this string.
Sometimes, Nahidul gets tired, and it's challenging for him to find the result, so he needs your help. Help him with this task.
Input
The first line contains a line of string (a portion of newspaper) 's' (all lowercase characters) of n characters where 2 ≤ n ≤ 106.
Output
Find out the average value of a string. Print "YES" (without quotes) and print the answer if it exists for any letter.
Otherwise print "The Nearly Answer is :" (without quotes) and the strictly less value than the answer.
Remember that the result will not exceed 32-bit data.
Example
Input: aabbc Output: YES 2
Input: aaaaa eeeee ccccbbddffg2 Output: The Nearly Answer is :2
Explanation
Example 1 has described above.
In example 2, a=5, e=5, c=4, b=2, d=2, f=2, g=1 and as stated in the third condition, character '2' is ignored.
Total = 5+5+4+2+2+2+1 = 21 and average = 21/7 = 3. As 3 is not frequency of any letter, So strictly less than 3 is 2, which is the answer.
Added by: | Ruhul |
Date: | 2019-08-04 |
Time limit: | 1s |
Source limit: | 20000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | C CPP14 JAVA PYTHON3 |
hide comments
2023-11-14 02:20:51 Oleg
Probably should be in tutorials... Last edit: 2023-11-14 06:38:20 |