47's Strings
/
No tags
Problem
Editorial
Analytics

Diana sent a message "S" to agent 47 in an encrypted language so that no one else can decode it.

Now a string in encrypted language is said to be valid if and only if it contains the characters '$' or '&' . Agent 47 decided to count the number of valid sub-strings of the message "S" sent by Diana . P.S. - '$' and '&' characters are considered as 4 -> '$' and 7 -> '&' in a key-board. Can you help Agent 47 , in counting the total no. of valid substrings in encrypted message. Note : Two sub-strings are different if they occur at different positions in the message. Input : • First line consists of a single integer 'T' , i.e. no. of test cases . • Each test case consists of a string "S",i.e the message sent by Diana Output : • For each test case, output a single integer containing the count of total no. of valid sub-strings in new line. Constraints : • 1<=T<=10 • 1<=|S|<=10^6 • Message 'S' contains only lower case letters and characters '$' and '&'
SAMPLE INPUT
2
$bcd flkjdh SAMPLE OUTPUT 4 0 Explanation • Sample test 1: For the first case, there are 4 sub-strings containing '$' .
• Sample test 2: There are no sub-strings having '\$' or '&'.
Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

## This Problem was Asked in

Initializing Code Editor...