結果

問題 No.346 チワワ数え上げ問題
ユーザー 👑 yumechiyumechi
提出日時 2016-03-08 22:00:11
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 589 bytes
コンパイル時間 1,686 ms
コンパイル使用メモリ 81,648 KB
実行使用メモリ 65,504 KB
最終ジャッジ日時 2023-10-24 20:24:02
合計ジャッジ時間 5,217 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
65,504 KB
testcase_01 AC 43 ms
55,488 KB
testcase_02 AC 40 ms
55,488 KB
testcase_03 AC 40 ms
55,488 KB
testcase_04 AC 41 ms
55,488 KB
testcase_05 AC 41 ms
55,488 KB
testcase_06 AC 43 ms
55,488 KB
testcase_07 AC 42 ms
55,488 KB
testcase_08 AC 42 ms
55,488 KB
testcase_09 AC 42 ms
55,488 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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()
0