val D = "1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991" fun f(n:Int): String { tailrec fun iter(i: Int, c: Int, sb: StringBuilder) { if (i>=0) { val t = n*D.slice(i..i).toInt()+c sb.insert(0,(t%10).toString()) return iter(i-1, t/10, sb) } else { if (c!=0) { sb.insert(0,c.toString()) } } } val sb = StringBuilder(D.length+2) val t = n*D.slice(D.length-1..D.length-1).toInt() sb.insert(0,(t%10).toString()) iter(D.length-2,t/10,sb) if (sb.length==D.length) sb.insert(0,"0.") else sb.insert(sb.length-D.length,".") return sb.toString() } fun g(m: Int, n: Int): String { fun f(a: Int, b: Int, c: Int) = if ((a+b+c)%10>9) 1 else 0 tailrec fun iter(i: Int, c: Int, c1: Int, c2: Int, t2: Int, sb: StringBuilder) { if (i>=0) { val t = D.slice(i..i).toInt() val t1 = n*t+c1 sb.insert(0,((t2+t1+c)%10).toString()) iter(i-1, f(t2,t1,c), t1/10, (m*t+c2)/10, m*t+c2, sb) } else { sb.insert(0,(t2+c1+c).toString()) } } val sb = StringBuilder(D.length+3) var t = D.slice(D.length-1..D.length-1).toInt() var t1 = n*t val t2 = m*t val c1 = t1/10 val c2 = t2/10 sb.insert(0,(t1%10).toString()) t = D.slice(D.length-2..D.length-2).toInt() t1 = n*t+c1 sb.insert(0,((t1+t2)%10).toString()) iter(D.length-3, f(t2,t1,0), t1/10, (m*t+c2)/10, m*t+c2, sb) sb.insert(sb.length-D.length,".") return sb.toString() } fun main(args: Array) { val s = readLine()!! when (s.length) { 1 -> println(f(s.toInt())) 2 -> println(g(s.slice(0..0).toInt(), s.slice(1..1).toInt())) else -> println(D.slice(0..1).plus(".").plus(D.slice(2..D.length-1))) } }