結果
| 問題 |
No.852 連続部分文字列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-01-18 06:56:16 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 360 ms / 3,153 ms |
| コード長 | 468 bytes |
| コンパイル時間 | 413 ms |
| コンパイル使用メモリ | 82,392 KB |
| 実行使用メモリ | 66,304 KB |
| 最終ジャッジ日時 | 2024-06-11 10:11:56 |
| 合計ジャッジ時間 | 7,417 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
ソースコード
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)