DCP-384: Counting Substring Back to All Problems

Medium Math > Counting

You are given a string S consist of character ‘a’ and ‘b’. You have to tell me the number of substring of the given string where there is at most one segment of character b. Suppose the string is “aabbab”. Then some of valid substrings are "a" , "b" , "abb" etc but “bbab” , “bab” etc are not the valid substrings. Input: ------ First line of input contains the number of test case T (1<=T<=100). Then each of the test case contains exactly one line of input string S. Size of the string S will be between 1 and 100000.. Output: ------- For each test cases output a line like **“Case X: Y”** without quotation where X denotes the number of test case and Y denotes the number of sub string of the given test case according to the problem. Sample Input ------------ 1 abba Sample Output ------------- Case 1: 10

Problem Setter:

Suman Bhadra

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 1.00
C++ 1.00
C++14 1.00
C# 2.00
Go 2.00
Java 2.00
JavaScript 2.00
Objective-C 2.00
Perl 2.00
PHP 2.00
Python 2.00
Python3 2.00
Ruby 2.00
VB.Net 2.00

Problem Stats




# User Language Timing
01 AlirezaNa Cpp14 0.12s
02 feodorv C 0.13s
03 Morass Cpp14 0.16s
04 BishalG Cpp 0.20s
05 seyedssz Cpp 0.23s
06 mahbubcseju Cpp 0.27s
07 sazal_dev Cpp 0.32s
08 MRoy Cpp14 0.40s
09 abid1 Cpp 0.52s

Your feedback is our precious!

Or call +88 02 9853138 for support