7 条题解
-
1
240216cj顾皓轩 LV 4 @ 1 年前
#include <iostream>
using namespace std;
int main()
{
int a,b,c,sum=0,d;
a=1; b=1;
cin>>d;
sum=a+b;
for(int i=3; i<=d; i++)
{c=a+b; sum=sum+c;
a=b; b=c;
}
cout<<sum<<endl;
return 0;
} -
14 年前@
include <iostream>
using namespace std;
int main()
{
int a,b,c,sum,d;
a=1; b=1;
cin>>d;
sum=a+b;
for(int i=3; i<=d; i++)
{
c=a+b; sum=sum+c;
a=b; b=c;
}
cout<<sum<<endl;
return 0;
} -
15 年前@
直接通过变量迭代实现……
-
15 年前@
-
02 年前@
#include <stdio.h>
//斐波拉契 i hate you!
int main() {
int a = 1, b = 1, c;
unsigned int n;
scanf("%ld", &n);
unsigned int sum = 2;
if (n == 1)
printf("1");
if (n == 2)
printf("2");
if (n > 2) {
for (int i = 3; i <= n; i++) {
c = a + b;
sum+=c;
a = b;
b = c;
}
printf("%ld", sum);
}return 0;
} -
-14 年前@
#include <iostream>
using namespace std;
int main()
{
int a,b,c,xs,x=2,m=1,d;
cin>>d;a=1;
b=1;while(m<=d-2)
{
c=a;
a=b;
b=a+c;
m++;xs=b;
x=x+xs;
}cout<<x;
return 0;
} -
-15 年前@
- 1
信息
- 难度
- 5
- 分类
- (无)
- 标签
- 递交数
- 2153
- 已通过
- 745
- 通过率
- 35%
- 被复制
- 8
- 上传者