Logo
(追記) (追記ここまで)

12072번 - Albocede DNA (Small) 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 512 MB70541862.069%

문제

The DNA of the Albocede alien species is made up of 4 types of nucleotides: a, b, c, and d. Different Albocedes may have different sequences of these nucleotides, but any Albocede's DNA sequence obeys all of the following rules:

  • It contains at least one copy of each of a, b, c, and d.
  • All as come before all bs, which come before all cs, which come before all ds.
  • There are exactly as many 'a's as 'c's.
  • There are exactly as many 'b's as 'd's.

For example, abcd and aabbbccddd are valid Albocede DNA sequences. acbd, abc, and abbccd are not.

The Albocede-n is an evolved species of Albocede. The DNA sequence of an Albocede-n consists of one or more valid Albocede DNA sequences, concatenated together end-to-end. For example, abcd and aaabcccdaabbbccdddabcd are valid Albocede-n DNA sequences. (Observe that a valid Albocede-n DNA sequence is not necessarily also a valid Albocede DNA sequence.)

From one of your alien expeditions, you retrieved an interesting sequence of DNA made up of only as, bs, cs, and ds. You are interested in how many of the different subsequences of that sequence would be valid Albocede-n DNA sequences. (Even if multiple different selections of nucleotides from the sequence produce the same valid subsequence, they still all count as distinct subsequences.) Since the result may be very large, please find it modulo 1000000007 (109 + 7).

입력

The first line of the input gives the number of test cases, T. Each of the next T lines contains a string S that consists only of the characters a, b, c, and d.

Limits

  • 1 ≤ T ≤ 20.
  • 1 ≤ length of S ≤ 50.

출력

For each test case, output one line containing "Case #x: y", where x is the test case number (starting from 1) and y is the output of the xth test case.

제한

예제 입력 1

5
abcd
aaaabcd
aaaabbccd
abcdabcdaabccd
b

예제 출력 1

Case #1: 1
Case #2: 4
Case #3: 28
Case #4: 71
Case #5: 0

힌트

출처

Contest > Google > Google's Coding Competitions > Google APAC 2016 University Graduates Test > Round B APAC Test 2016 D1번

Contest > Google > Kick Start > Google Kick Start 2015 > Round B D1번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /