No.279 Counting Trees
タグ : / 解いたユーザー数 753
作問者 :
紙ぺーぱー
Problem Statement
kamipeipaa loves trees, but today he is playing with strings.
He is curious about how many substrings "tree" can be formed by rearranging the string $S$. Please tell him.
Input
$S$
The string $S(1 \le |S| \le 10^{6})$ that kamipeipaa has, consisting only of lowercase English letters, is given in one line.
Output
Output in one line the maximum number of substrings "tree" that can be formed by freely rearranging $S$. Do not forget the newline.
Sample
Sample 1
Input
takahashikunlovesyukicoder
Output
1
"takahashikunlovesyukicoder" can be rearranged into "treeakahashikunlovsyukicod", which contains one substring "tree".
Sample 2
Input
treapisnotki
Output
0
No matter how "treapisnotki" is rearranged, the substring "tree" cannot be obtained.
Sample 3
Input
eerteerteerteert
Output
4
The string "eerteerteerteert" can be rearranged into "treetreetreetree", which contains four substrings "tree".
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。