LCPC12A - Johnny divides by 2

no tags 


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 Format

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 Format

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

Sample Output




1. 2 4


hide comments
Samil Vargas: 2014-01-06 21:09:01

1 2 3 4 5 12 23 34 45 123 234 345 1234 2345 12345

nani: 2012-10-06 09:26:43

Last edit: 2014-02-08 03:30:23
Pranay: 2012-10-05 22:24:35

so should the answer for 1021 be 9 1 or 4 3 ?

:D: 2012-10-05 18:05:56

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.

Damian Straszak: 2012-10-05 14:38:49

How to deal with leading zeros? E.g. what is the answer to "1021"?

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