fun main(args: Array) { val rd = Reader() val S = rd.string() val N = S.length val mae = IntArray(26, {-1}) var kotae = 0L for (i in 0..N-1) { kotae += (i - mae[S[i] - 'a']).toLong() * (N - i) mae[S[i] - 'a'] = i } println(kotae) println(2.0 * kotae / N / (N + 1)) } class Reader { var buf: ByteArray = ByteArray(5000000) var k: Int = 0 var n: Int = 0 init { check() } private fun check() { if (k == n) { n = System.`in`.read(buf) k = 0 } } private fun peek(): Byte { return buf[k] } private fun next() { k++ check() } fun string(): String { var ans = StringBuilder() while ('0'.toByte() > peek()) next() while ('0'.toByte() <= peek()) { ans.append(peek().toChar()) next() } return ans.toString() } fun long(): Long { var ans: Long = 0 while ('0'.toByte() > peek()) next() while ('0'.toByte() <= peek()) { ans = ans * 10 + (peek() - '0'.toLong()) next() } return ans } fun int(): Int { return long().toInt() } }