Golang | Leetcode Golang题解之第70题爬楼梯

题目:

题解:

Go 复制代码
func climbStairs(n int) int {
    sqrt5 := math.Sqrt(5)
    pow1 := math.Pow((1+sqrt5)/2, float64(n+1))
    pow2 := math.Pow((1-sqrt5)/2, float64(n+1))
    return int(math.Round((pow1 - pow2) / sqrt5))
}
相关推荐
程序员烧烤1 小时前
【leetcode刷题007】leetcode116、117
算法·leetcode
Swift社区4 小时前
LeetCode 395 - 至少有 K 个重复字符的最长子串
算法·leetcode·职场和发展
Espresso Macchiato4 小时前
Leetcode 3710. Maximum Partition Factor
leetcode·职场和发展·广度优先遍历·二分法·leetcode hard·leetcode 3710·leetcode双周赛167
巴里巴气5 小时前
第15题 三数之和
数据结构·算法·leetcode
一根甜苦瓜5 小时前
Go语言Slice的一道骚题
开发语言·后端·golang
驰羽5 小时前
[GO]Go语言泛型详解
开发语言·golang·xcode
NPE~5 小时前
[手写系列]Go手写db — — 第五版(实现数据库操作模块)
开发语言·数据库·后端·golang·教程·手写系列·手写数据库
西阳未落6 小时前
LeetCode——双指针(进阶)
c++·算法·leetcode
熬了夜的程序员7 小时前
【LeetCode】69. x 的平方根
开发语言·算法·leetcode·职场和发展·动态规划
Swift社区16 小时前
LeetCode 394. 字符串解码(Decode String)
算法·leetcode·职场和发展