結果
問題 | No.852 連続部分文字列 |
ユーザー |
|
提出日時 | 2019-07-27 01:07:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 3,153 ms |
コード長 | 438 bytes |
コンパイル時間 | 2,220 ms |
コンパイル使用メモリ | 193,816 KB |
最終ジャッジ日時 | 2025-01-07 09:00:19 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); string s; cin >> s; vector<int> pre(26, -1); long long tot = 0; int n = (int) s.size(); for (int i = 0; i < n; i++) { tot += 1LL * (i - pre[s[i] - 'a']) * (n - i); pre[s[i] - 'a'] = i; } cout << setprecision(20) << fixed << 1.0 * tot / (1LL * n * (n + 1) / 2) << endl; return 0; }