LCPC12A - Johnny divides by 2

Johnny is studying division and he started by division by 2. To practice division, his colleague gave him a set of problems as follows: Given a string S of length L all containing digits from 0 to 9 (with no leading zeros), how many substring of S can be divided by 2 with no remainder, and how many cannot be divided by 2 with no remainder. For example string "123" has six substrings "1", "2", "3", "12", "23", and "123". Four of which cannot be divided by 2 with no remainder, which are "1", "3", "23", and "123" and only two substrings can be divided by 2 with no remainder, which are "2", and "12". Since Johnny feels that he may solve them incorrectly specially that his colleague gave him a lot of them, he decided to write this problem and submit it to the LCPC chief judge to put it in the contest for the LCPC teams to solve it, and so Johnny will get back a program that generate the solution to verify his answers.

Input

Input will start with T number of test cases. Followed by T lines each line contains string S with length 0 < L < 10 of digits 0-9.

Output

For each test case, output the result using the following format:

k. D N

Where k is the test case number (starting at 1), a single period, a single space, then D (how many substrings of S can be divided by 2 with no remainder), N (how many cannot be divided by 2 with no remainder).

Sample

Input
1
123

Output
1. 2 4

Added by:Gareev
Date:2012-10-05
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:LCPC 2012

hide comments
2014-01-06 21:09:01 Samil Vargas
12345
1 2 3 4 5 12 23 34 45 123 234 345 1234 2345 12345
2012-10-05 22:24:35 Pranay
so should the answer for 1021 be 9 1 or 4 3 ?
2012-10-05 18:05:56 :D
Every substring is valid and counted separately. Just trunc leading zeros to get the actual values.

The problem is way too easy for classical. It's still an interesting template. String should be way longer (10^5) and division should be by 3,9 or maybe even 7.
2012-10-05 14:38:49 Damian Straszak
How to deal with leading zeros? E.g. what is the answer to "1021"?
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.