#include #include #include #include #include #include #include #include #include #include #include #include #include #pragma warning(disable:4996) typedef long long ll; #define MIN(a, b) ((a)>(b)? (b): (a)) #define MAX(a, b) ((a)<(b)? (b): (a)) #define LINF 9223300000000000000 #define INF 2140000000 const long long MOD = 1000000007; using namespace std; char str[1000005]; int main(int argc, char* argv[]) { scanf("%s", str); map z; map val; int len=strlen(str); int i; for(i=0; isecond+1; } if(i-tmp>0) { val[str[i]] += (double)(i-tmp)*(i-tmp+1)/2; } z[str[i]]=i; } double ans=0; auto it=z.begin(); for(; it!=z.end(); ++it) { int tmp=it->second+1; if(len-tmp>0) { val[it->first] += (double)(len-tmp)*(len-tmp+1)/2; } ans += ((double)len*(len+1)/2-val[it->first]); } printf("%.10lf\n", ans / ((double)len*(len+1)/2) ); return 0; }