結果
| 問題 |
No.346 チワワ数え上げ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-03-08 21:59:45 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 589 bytes |
| コンパイル時間 | 124 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 18,332 KB |
| 最終ジャッジ日時 | 2024-09-24 15:27:03 |
| 合計ジャッジ時間 | 4,056 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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()