Submit | All submissions | Best solutions | Back to list |
BUBTPC - BUBT Programming Club |
Write a program which accepts a variable number of strings as input and locates the position of the string 'BUBT' and the string 'Programming' in each input. The program should print the sum of the positions found. If a particular string is not found then the position should be considered to be -1.
For example, if the string 'BUBTProgrammingClub' is supplied to the program, the string 'BUBT' lies at position 0 (considering the first position to be zero) and the second string 'Programming' lies at position 4, hence the sum of the positions will be 4 + 1 = 5. Similarly if the word 'Testprogram' is supplied to the program, both 'BUBT' and 'Programming' are not present, hence the result will be (-1) + (-1) = -2.
Input
Input start with an integer T (1 ≤ T ≤ 1000 ) denoting the number of test cases. Each case contains a string. String length is not greater than 10000000 (107). Assume that all character is in uppercase (A-Z), lowercase (a-z) and numeric (0-9).
Output
For each case, print the case number and sum of position. See the sample input/output for exact formatting.
Example
Input: 3 BUBTProgrammingClub Testprogram BUBTBUBT Output: Case 1: 4 Case 2: -2 Case 3: 3
Problem Setter: Shipu Ahamed , Dept. of CSE
Bangladesh University of Business and Technology (BUBT)
Added by: | Shipu Ahamed |
Date: | 2013-06-17 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
hide comments
2014-05-12 15:46:54 [Lakshman]
@All those who are getting WA there is space between case number and answer. Case 1: 4 Case 2: -2 Case 3: 3 Last edit: 2013-12-07 15:53:43 |