結果

問題 No.852 連続部分文字列
ユーザー jensenjensen
提出日時 2021-01-21 19:24:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,695 ms / 3,153 ms
コード長 403 bytes
コンパイル時間 219 ms
コンパイル使用メモリ 10,960 KB
実行使用メモリ 25,380 KB
最終ジャッジ日時 2023-08-26 06:35:16
合計ジャッジ時間 22,658 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,836 KB
testcase_01 AC 16 ms
7,912 KB
testcase_02 AC 16 ms
7,912 KB
testcase_03 AC 15 ms
7,932 KB
testcase_04 AC 16 ms
7,836 KB
testcase_05 AC 16 ms
7,884 KB
testcase_06 AC 16 ms
7,920 KB
testcase_07 AC 16 ms
7,804 KB
testcase_08 AC 16 ms
7,788 KB
testcase_09 AC 16 ms
7,812 KB
testcase_10 AC 16 ms
7,916 KB
testcase_11 AC 16 ms
7,864 KB
testcase_12 AC 16 ms
7,916 KB
testcase_13 AC 43 ms
8,088 KB
testcase_14 AC 28 ms
7,836 KB
testcase_15 AC 61 ms
8,236 KB
testcase_16 AC 43 ms
8,048 KB
testcase_17 AC 54 ms
8,040 KB
testcase_18 AC 63 ms
8,176 KB
testcase_19 AC 19 ms
7,784 KB
testcase_20 AC 38 ms
7,832 KB
testcase_21 AC 65 ms
8,160 KB
testcase_22 AC 31 ms
7,916 KB
testcase_23 AC 49 ms
8,024 KB
testcase_24 AC 34 ms
7,832 KB
testcase_25 AC 48 ms
8,068 KB
testcase_26 AC 64 ms
8,204 KB
testcase_27 AC 44 ms
7,916 KB
testcase_28 AC 54 ms
7,992 KB
testcase_29 AC 65 ms
8,128 KB
testcase_30 AC 24 ms
7,920 KB
testcase_31 AC 67 ms
8,208 KB
testcase_32 AC 69 ms
8,200 KB
testcase_33 AC 1,656 ms
14,964 KB
testcase_34 AC 1,652 ms
14,876 KB
testcase_35 AC 1,661 ms
15,016 KB
testcase_36 AC 1,657 ms
14,836 KB
testcase_37 AC 1,654 ms
14,824 KB
testcase_38 AC 1,657 ms
15,016 KB
testcase_39 AC 1,678 ms
14,956 KB
testcase_40 AC 1,651 ms
14,756 KB
testcase_41 AC 1,652 ms
14,828 KB
testcase_42 AC 1,695 ms
12,320 KB
testcase_43 AC 1,663 ms
25,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s=input()
s_lng=len(s)
af=[chr(i) for i in range(97, 97+26)]
cnt=0
for moji in af:
    idx=[i for i,x in enumerate(s) if x==moji]
    if(len(idx)>1):
        m=sum(idx[1:len(idx)-1])
        n=0
        for i in range(len(idx)-1):
            n+=idx[i]*idx[i+1]
        cnt+=(s_lng*idx[0]+(s_lng-1)*m-idx[len(idx)-1]-n+(len(idx)-1)*s_lng)
u=s_lng*(s_lng+1)*(s_lng+2)/6-cnt
l=s_lng*(s_lng+1)/2
print(u/l)
0