---
# System prepended metadata

title: 'a830: 超級細菌( bacteria )'
tags: [蘿莉控自學]

---

---
tags: 蘿莉控自學
---
> 蘿莉控的C++自學筆記
# a830: 超級細菌( bacteria )
連結: https://zerojudge.tw/ShowProblem?problemid=a830
AC(2ms, 324KB)
解題過程影片:(無人聲)
(1) https://youtu.be/ecWKldKFZI0
(2_debug) https://youtu.be/OByfsMBQ8To 
```cpp=
#include<bits/stdc++.h>
using namespace std;
int M, N, W, X, Y, Z;
int dpM[105] = {0};
int dpN[105] = {0};
int sum_m;
int sum_n;
int main(){
    cin >> M >> N >> W >> X >> Y >> Z;
    int sum_m = M;
    int sum_n = N;
    dpM[0] = M;
    dpN[0] = N;
    for(int i = 1;i <= W;i ++){
        //old
        int t = 0;
        int k = i-Y;
        while(k >= 0){
            t += dpM[k];
            k -= Y;
        }// i-Y, i-2Y....
        dpN[i] = t * Z;
        sum_n += dpN[i];
        //new
        if (i - X >= 0){ // i-X, i-2X....
            dpM[i] = dpN[i-X];
            sum_m += dpM[i];
            sum_n -= dpN[i-X];
            dpN[i-X] = 0;
        }
    }
    cout << sum_m + sum_n;
} //	AC (2ms, 324KB) 	


```