这道题没有什么坑,就是要用到两个math库函数pow,sqrt。
#include<stdio.h>
#include<math.h>
int main()
{
int n;
double s = 0; ;
scanf("%d", &n);
s =( pow((1+sqrt(5))/2,n)- pow((1 - sqrt(5)) / 2, n))/sqrt(5);
printf("%.2lf", s);
return 0;
}
这道题没有什么坑,就是要用到两个math库函数pow,sqrt。
#include<stdio.h>
#include<math.h>
int main()
{
int n;
double s = 0; ;
scanf("%d", &n);
s =( pow((1+sqrt(5))/2,n)- pow((1 - sqrt(5)) / 2, n))/sqrt(5);
printf("%.2lf", s);
return 0;
}