题解 | #跳台阶扩展问题# | Golang
跳台阶扩展问题
https://www.nowcoder.com/practice/953b74ca5c4d44bb91f39ac4ddea0fee
package main
import (
"fmt"
)
type Solution struct {
N int
}
func (s Solution) countWays() int {
prefix := 0
ans := 0
for i:=1; i<=s.N; i++ {
ans = prefix + 1
prefix+=ans
}
return ans
}
func main() {
n := 0
fmt.Scan(&n)
fmt.Print(Solution{N:n}.countWays())
}

