1 条题解

  • 1
    @ 2025-5-31 20:54:13
    #include <bits/stdc++.h>
    #define endl '\n'
    using namespace std;
    using ll = long long;
    
    void solve()
    {
        int x, y, z;
        cin >> x >> y >> z;
        
        vector<ll> adults(z + 1, 0);
        vector<ll> luan(z + 1, 0);
        
        adults[0] = 1;
        
        for (int i = 0; i <= z; i++)
        {
        	// adults[i] 表示第i个月的成虫数
        	// luan[i] 表示第i个月新产生的卵数
            if (i >= 1) adults[i] += adults[i-1];
            if (i >= 2) adults[i] += luan[i-2];
            
            // 当前月的成虫产生卵
            if (i - x >= 0)
            {
                luan[i] = adults[i - x] * y;
            }
        }
        cout << adults[z] << endl;
    }
    
    int main()
    {
        ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
        int _ = 1;
        while (_--)
        {
            solve();
        }
        return 0;
    }
    • 1

    信息

    ID
    318
    时间
    1000ms
    内存
    256MiB
    难度
    10
    标签
    递交数
    1
    已通过
    1
    上传者