1 条题解
-
0
C :
#include<stdio.h> int main(void) { int x1,x2,x3,y1,y2,y3,N; scanf("%d",&N); if(N==1) printf("2\n"); else { if(N==2) printf("3.5\n"); else { int i; double s=3.5; x1=2; x2=3; y1=1; y2=2; for(i=3;i<=N;i++) { x3=x1+x2; y3=y1+y2; s+=x3*1.0/y3; x1=x2; x2=x3; y1=y2; y2=y3; } printf("%.2f\n",s); } } }
C++ :
#include <bits/stdc++.h> using namespace std; long long n; float s,a=2,b=1,t; int main() { cin>>n; for(int i=1;i<=n;i++) s=s+1/b*a,t=b+a,b=a,a=t; printf("%.2f",s); return 0; }
- 1
信息
- ID
- 1607
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者