3 条题解

  • 0
    @ 2024-5-19 18:54:46

    #include<iostream> #include<cstdio> #include<cstring> #include<iomanip> #include<cmath> #include<algorithm> const int N = 1e7 + 10; const int INF = 0x3f3f3f3f; using namespace std; long long a[N],b[N],x,y,z; int main(){ cin>>x>>y>>z; for(int i=0;i<x;i++) { b[i]=0; a[i]=1; } for(int i=x;i<=z;i++) { a[i]=a[i-1]+b[i-2]; b[i]=a[i-x]*y; } cout<<a[z]; return 0; }

    • 0
      #include <bits/stdc++.h>
      using namespace std;
      const int N=1e2+10;
      long long bug[60],egg[60];
      int x,y,z; 
      int main()
      {
      	cin>>x>>y>>z;
      	z++;
      	bug[1]=1;
      	for(int i=2;i<=z;i++)
      	{
      		if(i>=2)
      		bug[i]=bug[i-1]+egg[i-2];
      		if(i>=x)
      		egg[i]=bug[i-x]*y;
      	}
      	cout<<bug[z];
      	return 0;
      }
      

      递推初学者噩梦

      • 0
        @ 2022-11-29 12:11:51

        #include<iostream> #include<cstdio> using namespace std;

        long long f[55];

        long long s[55];

        int main() {

        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        f[1]=1;
        for(int i=2;i<=z+1;i++)
        {
        	f[i]=f[i-1]+s[i-2]; //新增成虫数
        	if(i>=x)    s[i]=f[i-x]*y; ////x个月前的虫卵数 
        }
        printf("%lld",f[z+1]);
        return 0;
        

        }

        • 1

        信息

        ID
        1266
        时间
        1000ms
        内存
        256MiB
        难度
        5
        标签
        递交数
        145
        已通过
        60
        上传者