1 solutions
-
0
C++ :
#include<iostream> #include<cstring> using namespace std; long long n,m,i,j,a[500],b[500],c[500]; int main() { cin>>n>>m; a[0]=1; a[1]=1; memset(b,0,sizeof(b)); b[0]=1; b[1]=0; for (j=n+1;j<=m;j++) { for (i=0;i<=a[0];i++) c[i]=a[i]; for (i=1;i<=a[0];i++) { a[i]+=b[i]; a[i+1]+=a[i]/10; a[i]%=10; } while (a[a[0]+1]>0) a[0]++; memset(b,sizeof(b),0); for (i=0;i<=c[0];i++) b[i]=c[i]; } for (i=a[0];i>=1;i--) cout<<a[i]; cout<<endl; return 0; }
Pascal :
var i,j,n,m:integer; b:array[0..1000,0..1000] of integer; l:array[0..1000]of integer; procedure work(x,y,z:integer); var i1,j1,l1:integer; begin if l[y]>l[z] then l1:=l[y] else l1:=l[z]; for i1:=1 to l1 do begin b[x,i1]:=b[y,i1]+b[z,i1]+b[x,i1]; b[x,i1+1]:=b[x,i1] div 10; b[x,i1]:=b[x,i1] mod 10; end; if b[x,l1+1]>0 then l[x]:=l1+1 else l[x]:=l1; end; begin readln(n,m); fillchar(b,sizeof(b),0); b[n,1]:=1; b[n+1,1]:=1; l[n]:=1; l[n+1]:=1; for i:=n+2 to m do begin work(i,i-1,i-2); end; for i:=l[m] downto 1 do write(b[m,i]); end.
- 1
Information
- ID
- 645
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By