TopcoderArchiveVisit Topcoder
SRM22 Nov 2011
SRM 541

AkariDaisukiDiv2

Problem statement, definition, constraints, and public examples.

Problem Statement

Consider the following function:
f(X) = Waai + X + Akari + X + Daisuki
Here, X is a string and + denotes string concatenation. Waai, Akari and Daisuki are constant non-empty strings.


You are given a String S. Compute and return the number of different tuples (Waai,Akari,Daisuki,X) such that f(X) equals S.

Definition

Class:
AkariDaisukiDiv2
Method:
countTuples
Parameters:
String
Returns:
int
Method signature:
int countTuples(String S)
(be sure your method is public)

Notes

  • Two tuples (A,B,C,D) and (E,F,G,H) are considered equal if and only if A=E, B=F, C=G, and D=H.

Constraints

  • S will contain between 1 and 50 characters, inclusive.
  • Each character of S will be a lowercase letter ('a'-'z').

Examples

  1. "topcoderdivtwo"
    Returns: 2
    The possible tuples of (Waai, Akari, Daisuki, X) are the following ones: ("t", "pc", "derdivtwo", "o") ("topco", "er", "ivtwo", "d") ("topc", "derdivtw", "", "o") is not allowed since Daisuki is empty.
  2. "foxciel"
    Returns: 0
    The answer can be zero.
  3. "magicalgirl"
    Returns: 4
  4. "waaiusushioakariusushiodaisuki"
    Returns: 75
  5. "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    Returns: 8924
Back to all problems