题解 | #扭蛋机#
扭蛋机
https://www.nowcoder.com/practice/9d26441a396242a9a0f7d2106fc130c7
package main import ( "fmt" ) func reverseString(s string) string { runes := []rune(s) for from, to := 0, len(runes)-1; from < to; from, to = from+1, to-1 { runes[from], runes[to] = runes[to], runes[from] } return string(runes) } func main() { n := 0 _, _ = fmt.Scan(&n) // fmt.Println(n) res := "" for n > 0 { if n%2 == 0 { n = (n - 2) / 2 res += "3" } else { n = (n - 1) / 2 res += "2" } } fmt.Println(reverseString(res)) }