Submit | All submissions | Best solutions | Back to list |
PCPC12B - Free Palestine |
Today after the Arab revolutions the main issue that concerns all the Arab and Islamic world is the Palestinian struggle against the Israeli Occupation. Millions of people post on social networks messages supporting Palestine, mostly on Facebook pages and on Twitter hash tags such as "#Palestine". You are given some posts and you are required to calculate the score of each post. Scores are computed as follows:
- Count the number of vowels (a, e, i, o, u) in the post. Let's call this value v.
- Calculate the sum of the absolute differences of the ASCII values of every pair of adjacent letters (the first and last letter are adjacent). Ignore the white spaces. Let's call this value d.
- The score is v*d.
For example “free palestine”: number of vowels v = 6. The sum d = [ abs(f-r) = 12 + abs(r-e) = 13 + abs(e-e) = 0 + abs(e-p) = 11 + ... + abs(n-e) = 9 + abs(e-f) = 1 ] = (12 + 13 + 0 + 11 + 15 + 11 + 7 + 14 + 1 + 11 + 5 + 9 + 1) = 110. The score is 660.
Input
The first line contains integer n number of posts. It is followed by n lines each containing one post. All characters will be lower case English letters and spaces. Number of characters in the post won't exceed 140 characters, and at least 1 non white space character.
Output
Print n lines each line containing a single integer, the score of the corresponding post.
Example
Input: 4 free palestine long live palestine long live gaza palestine tomorrow will be free eeee eeee Output: 660 3096 1958 0
Added by: | abdelkarim |
Date: | 2012-12-28 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | The First Palestinian Collegiate Programming Contest |
hide comments
2016-03-12 17:11:35
Do the input cases have to be line after line? |
|
2016-03-12 16:52:10
long live Palestine |