結果

問題 No.852 連続部分文字列
ユーザー ああああ
提出日時 2023-01-18 06:56:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 376 ms / 3,153 ms
コード長 468 bytes
コンパイル時間 359 ms
コンパイル使用メモリ 87,348 KB
実行使用メモリ 78,088 KB
最終ジャッジ日時 2023-09-02 03:33:09
合計ジャッジ時間 8,833 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,508 KB
testcase_01 AC 68 ms
71,384 KB
testcase_02 AC 70 ms
71,384 KB
testcase_03 AC 67 ms
71,508 KB
testcase_04 AC 64 ms
71,120 KB
testcase_05 AC 72 ms
75,768 KB
testcase_06 AC 70 ms
75,568 KB
testcase_07 AC 70 ms
76,016 KB
testcase_08 AC 69 ms
71,576 KB
testcase_09 AC 66 ms
71,340 KB
testcase_10 AC 69 ms
75,700 KB
testcase_11 AC 67 ms
71,536 KB
testcase_12 AC 70 ms
75,792 KB
testcase_13 AC 76 ms
76,032 KB
testcase_14 AC 77 ms
75,948 KB
testcase_15 AC 78 ms
75,932 KB
testcase_16 AC 76 ms
76,188 KB
testcase_17 AC 78 ms
76,172 KB
testcase_18 AC 80 ms
76,080 KB
testcase_19 AC 72 ms
76,104 KB
testcase_20 AC 76 ms
76,108 KB
testcase_21 AC 82 ms
75,936 KB
testcase_22 AC 76 ms
75,856 KB
testcase_23 AC 78 ms
76,132 KB
testcase_24 AC 76 ms
76,100 KB
testcase_25 AC 79 ms
76,092 KB
testcase_26 AC 80 ms
75,964 KB
testcase_27 AC 77 ms
75,936 KB
testcase_28 AC 79 ms
75,996 KB
testcase_29 AC 78 ms
76,108 KB
testcase_30 AC 72 ms
75,844 KB
testcase_31 AC 80 ms
75,992 KB
testcase_32 AC 85 ms
76,060 KB
testcase_33 AC 274 ms
77,924 KB
testcase_34 AC 269 ms
78,072 KB
testcase_35 AC 265 ms
77,924 KB
testcase_36 AC 268 ms
78,016 KB
testcase_37 AC 278 ms
77,972 KB
testcase_38 AC 269 ms
77,992 KB
testcase_39 AC 376 ms
77,900 KB
testcase_40 AC 264 ms
78,000 KB
testcase_41 AC 279 ms
77,696 KB
testcase_42 AC 363 ms
78,088 KB
testcase_43 AC 264 ms
77,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

alph = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

s = input()
n = len(s)
ans = 0.0
all_num = n * (n + 1) // 2
for i in range(26):
    res = 0
    cnt = 0
    for j in range(n):
        if s[j] == alph[i]:
            res += cnt * (cnt + 1) // 2
            cnt = 0
        else:
            cnt += 1
    res += cnt * (cnt + 1) // 2
    ans += (all_num - res) / all_num
print(ans)
0