https://www.acmicpc.net/problem/5692
import java.util.*
import java.lang.String.format
fun main(args: Array<String>) {
val s=Scanner(System.`in`)
while(true){
var a=s.nextInt()
if(a==0) break
var count=1
var num=1
var sum=0
while(a>0){
var n=a%10
sum+=n*num
a/=10
num*=++count
}
println(sum)
}
}