@[linchenyu123](/user/1016616) 看看我的
```cpp
#include<bits/stdc++.h>
using namespace std;
long long n,a=1,b=1,c=0,i;
long long f(long long x){
for(i=3;i<=x;++i){
c=a+b;
a=b;
b=c;
}
return c;
}
int main() {
cin>>n;
cout<<f(n)<<".00";
return 0;
}
```
如果有帮助就给个关注吧谢谢喵!
by FurippuWRY @ 2023-08-22 12:03:01
保留2位小数
by Libingyue2011 @ 2023-08-22 12:08:47
给个关注吧。
by Libingyue2011 @ 2023-08-22 12:09:10
@[linchenyu123](/user/1016616)
```cpp
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int n;
cin>>n;
cout<<pow(((1+sqrt(5))/2),n)-pow(((1-sqrt(5))/2),n)/sqrt(5)<<".00<<endl;
return 0;
}
```
by Gohldg @ 2023-08-22 12:09:49
@[linchenyu123](/user/1016616) 以上是修改后的代码(~~完全没看~~)
只加上了```cout <<".00";```
by Gohldg @ 2023-08-22 12:12:26
还要改头文件
by myzzym @ 2023-08-22 12:27:22
还有式子都是错的???算了重写吧
by myzzym @ 2023-08-22 12:28:48
格式也是错的
by myzzym @ 2023-08-22 12:29:45
```cpp
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
printf("%.2f",(pow(((1+sqrt(5))/2),n)-pow(((1-sqrt(5))/2),n))/sqrt(5));
return 0;
}
```
by myzzym @ 2023-08-22 12:36:55