#include #include #include using namespace std; int main(int argc, char* argv[]) { string S; cin>>S; int i,len; double S1=0,S2=0; set mySet; size_t sLen=S.size(); for (len=1;len<=sLen;len++){ for (i=0;i<=sLen-len;i++){ string str1=S.substr(i,len); mySet.insert(str1); } S1+=len*(int)mySet.size(); S2+=(int)mySet.size(); mySet.clear(); } printf("%.5lf",S1/S2); return 0; }