結果
問題 |
No.346 チワワ数え上げ問題
|
ユーザー |
|
提出日時 | 2016-03-08 22:00:11 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 589 bytes |
コンパイル時間 | 558 ms |
コンパイル使用メモリ | 82,520 KB |
実行使用メモリ | 93,920 KB |
最終ジャッジ日時 | 2024-09-24 15:28:23 |
合計ジャッジ時間 | 4,325 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 10 TLE * 1 -- * 12 |
ソースコード
from functools import reduce from operator import mul # nC2 def combi(n): nr = reduce(mul, [i for i in range(1, n)]) return (nr * n * (n-1)) / (2 * nr) def solve(): s = input() cl, wl = [], [] slen = len(s) for i in range(slen): if s[i] == "c": cl.append(i) continue elif s[i] == "w": wl.append(i) res = 0 for cidx in cl: wlen = len([0 for i in wl if i > cidx]) if wlen < 2: break res += int(combi(wlen)) print(res) if __name__=="__main__": solve()