#B4318. Sum Parity of Numbers in Processed Poem
Sum Parity of Numbers in Processed Poem
Sum Parity of Numbers in Processed Poem
yummy is fascinated by traditional Chinese poems that contain numbers. Recently, he became interested in the sum of the numbers that appear in these poems. However, directly searching for numbers in Chinese text is hard, so yummy processes the poems with the following rules:
- Replace each group of characters that form a complete integer (possibly multiple Chinese numeral characters representing a number) with its corresponding Arabic numeral (note: the replacement is done as a whole, not character by character). Other characters are converted to their pinyin representation.
- If two adjacent numbers in the original text should not be connected, an underscore (
_
) is inserted between them. For example,八九十枝花
is processed as8_9_10zhihua
. - Only four punctuation marks are kept: comma, period, question mark, and exclamation mark. They are all the English half-width symbols:
, . ? !
. Note that unlike traditional Chinese layout, no space is inserted after punctuation.
After processing, the poem text only consists of lowercase English letters, digits, commas, periods, question marks, exclamation marks, and underscores.
For this problem, you are given such a processed poem text. The poem is divided into sentences. A sentence is defined as a fragment delimited by a period (.
), question mark (?
), or exclamation mark (!
). (A comma (,
) does not separate sentences.) For each sentence, you need to find all integer numbers (a number is defined as a maximal contiguous sequence of digits) and compute two results:
- The number of integers in the sentence.
- The parity (even or odd) of the sum of these integers. (For a sentence with no numbers, consider the sum as 0, which is even.)
Output one line for each sentence, containing the count and the parity (use the string even
or odd
), separated by a space, in the order they appear in the input.
inputFormat
The input consists of a single string representing the processed poem text. The string contains only lowercase English letters, digits, underscores, and the punctuation characters , . ? !
.
outputFormat
For each sentence in the input (determined by the delimiters period, question mark, or exclamation mark), output a line containing two items separated by a space: the count of numbers found in the sentence, and the parity of their sum (even
or odd
). Each sentence’s result should be printed on a separate line.
sample
43nian.
1 odd