結果

問題 No.852 連続部分文字列
ユーザー tanon710
提出日時 2019-07-27 00:00:57
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 597 ms / 3,153 ms
コード長 203 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 12,664 KB
最終ジャッジ日時 2024-07-02 10:10:02
合計ジャッジ時間 9,164 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

s=input()
l=len(s)
pos={}
alpha='abcdefghijklmnopqrstuvwxyz'
for char in alpha:
    pos[char]=-1
ans=0
dp=0
for i in range(l):
    dp+=i-pos[s[i]]
    ans+=dp
    pos[s[i]]=i
ans/=(l*(l+1))//2
print(ans)
0