using golang's math/big library, otherwise, one can use string to represent the input integer n(n <= 10^100).
package main
import (
"fmt"
"math/big"
)
func digits(n *big.Int) []int64 {
d := make([]int64, 0)
zero := big.NewInt(0)
ten := big.NewInt(10)
mod := big.NewInt(0)
for n.Cmp(zero) > 0 {
n, mod = n.DivMod(n, ten, mod)
d = append(d, mod.Int64())
}
return d
}
func main() {
var n big.Int
_, err := fmt.Scanf("%v", &n)
if err != nil {
fmt.Println(err)
}
var d []int64 = digits(&n)
//fmt.Println(d)
sum := big.NewInt(0)
for i := 0; i < len(d); i++ {
sum = sum.Add(sum, big.NewInt(d[i]))
}
d = digits(sum)
en2ch := map[int64]string{0:"ling", 1:"yi", 2:"er", 3:"san", 4:"si", 5:"wu", 6:"liu", 7:"qi", 8:"ba", 9:"jiu"}
for i := len(d)-1; i >= 0; i-- {
if i < len(d)-1 {
fmt.Print(" ")
}
fmt.Print(en2ch[d[i]])
}
fmt.Print("\n")
}