結果

問題 No.346 チワワ数え上げ問題
ユーザー 👑 yumechiyumechi
提出日時 2016-03-08 21:59:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 589 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 11,928 KB
実行使用メモリ 9,992 KB
最終ジャッジ日時 2023-10-24 20:23:26
合計ジャッジ時間 4,013 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
9,992 KB
testcase_01 AC 27 ms
9,992 KB
testcase_02 AC 28 ms
9,992 KB
testcase_03 AC 27 ms
9,992 KB
testcase_04 AC 27 ms
9,992 KB
testcase_05 AC 27 ms
9,992 KB
testcase_06 AC 27 ms
9,992 KB
testcase_07 AC 27 ms
9,992 KB
testcase_08 AC 27 ms
9,992 KB
testcase_09 AC 27 ms
9,992 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