1 solutions
-
0
C++ :
#include<iostream> #include<cstdlib> const int b=1000; long long a[b]; using namespace std; int main() { int n; cin>>n; a[1]=1; a[2]=1; a[3]=2; for(int i=4;i<=n;++i) a[i]=a[i-1]+a[i-2]; cout<<a[n]; //system("pause"); return 0; }Pascal :
var a:array[1..10000] of longint; n,i:longint; begin readln(n); a[1]:=1; a[2]:=1; for i:=3 to n do a[i]:=a[i-1]+a[i-2]; writeln(a[n]); end.
- 1
Information
- ID
- 17085
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By