long long mod = 1e9 + 7;
int fib(int n) {
if (n < 2) return n;
int prepre = 0, pre = 1, res;
for (int i = 2; i <= n; i++) {
res = (prepre % mod + pre % mod) % mod;
prepre = pre;
pre = res;
}
return res;
}
感觉效率有点低
标签:10,Offer,int,long,斐波,那契 From: https://www.cnblogs.com/yaocy/p/17125335.html