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
hide comments
Samil Vargas:
2014-01-06 21:09:01
12345
|
|
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.
|
|
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 |
Date: | 2012-10-05 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | LCPC 2012 |