• 沒有找到結果。

could be used as answers to the challenge. However, the former word was preferred because it was longer.

N/A
N/A
Protected

Academic year: 2021

Share "could be used as answers to the challenge. However, the former word was preferred because it was longer."

Copied!
1
0
0

加載中.... (立即查看全文)

全文

(1)

13257 License Plates

On their daily drive to high school, Antonia and her mom Maria, used to challenge each other using the license plates of other cars. In their country, license plates always contain a string of exactly three letters. The challenge was to tell the longest word that contains as a subsequence the string of letters found in a license plate.

For example, if a license plate contained the string “OMI”, then “PROGRAMMING” and “COLOMBIA”

could be used as answers to the challenge. However, the former word was preferred because it was longer.

Those were the old days. Antonia is now a Computer Science student and Maria wants to make some changes to keep the challenge interesting to her daughter. In the new version of the challenge, Maria writes down a word S and Antonia must calculate the number of different three-letter strings that are each a subsequence of S.

You must write a program to help Maria calculate in advance the output of the new version of the challenge.

Input

The first line of input contains T (T ≥ 0) indicating the number of test cases. Each test case consists of one single line containing a string S (1 ≤ |S| ≤ 10

5

). You may assume that S is made only of uppercase letters from the English alphabet (i.e., ‘A’, ‘B’, ..., ‘Z’) and that there is no blank line between test cases.

Output

For each test case, print a single line containing the number of different three-letter strings that are each a subsequence of S.

Sample Input 5

PROGRAMMING COLOMBIA NUEVE AAAAAAA PQ

Sample Output 110

46

9

1

0

參考文獻

相關文件

Once you get down to a purely business level, your influence is gone and the true light of your life isdimmed. You must work in the missionary spirit, with a breadth of charity

6 《中論·觀因緣品》,《佛藏要籍選刊》第 9 冊,上海古籍出版社 1994 年版,第 1

You are given the wavelength and total energy of a light pulse and asked to find the number of photons it

Then, it is easy to see that there are 9 problems for which the iterative numbers of the algorithm using ψ α,θ,p in the case of θ = 1 and p = 3 are less than the one of the

volume suppressed mass: (TeV) 2 /M P ∼ 10 −4 eV → mm range can be experimentally tested for any number of extra dimensions - Light U(1) gauge bosons: no derivative couplings. =>

We explicitly saw the dimensional reason for the occurrence of the magnetic catalysis on the basis of the scaling argument. However, the precise form of gap depends

incapable to extract any quantities from QCD, nor to tackle the most interesting physics, namely, the spontaneously chiral symmetry breaking and the color confinement.. 

• Formation of massive primordial stars as origin of objects in the early universe. • Supernova explosions might be visible to the most