1 solutions

  • 0
    @ 2024-12-10 23:55:33

    C++ :

    #include<iostream>
    #include<cstring>
    #include<cstdio>
    using namespace std;
    int main()
    {
    	//freopen("test0.in","r",stdin);
    	//freopen("test0.out","w",stdout);
    	long long a[101]={0},b[101]={0};
    	int i,j,x,y,z;
    	cin>>x>>y>>z;
    	for(i=1;i<=x;i++)
    	{
    		a[i]=1;
    		b[i]=0;
    	}
    	for(i=x+1;i<=z+1;i++)
    	{
    		b[i]=y*a[i-x];
    		a[i]=a[i-1]+b[i-2];
    	}	
    	cout<<a[z+1]<<endl;
    	return 0;
    }
    

    Pascal :

    program sssss(input,output);
    var
            a,b:array[-1000..20000] of int64;
            x,y,z:longint;
            i,j:longint;
    begin
            readln(x,y,z);
            a[1]:=1;
            b[1]:=0;
            for i:=2 to z+1 do
            begin
                    if i-x>=0 then
                            b[i]:=a[i-x]*y;
                    a[i]:=a[i-1]+b[i-2];
            end;
            writeln(a[z+1]);
    end.
    
    
    • 1

    Information

    ID
    651
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By