Q4

mail@pastecode.io avatar
unknown
c_cpp
9 days ago
493 B
3
Indexable
Never
#include <iostream>
#include <vector>

using namespace std;

int main(){
    const int MAX_N = 50; 
    vector<long long> male(MAX_N + 1, 0);
    vector<long long> total(MAX_N + 1, 0);

    male[0] = 0; 
    total [0] = 1;
    for(int i = 1; i <= MAX_N; i++) {
        male[i] = total[i-1];
        total[i] = male[i] + total[i-1]; 
    }

    int N;
    cin >> N;
    while(N != -1) {
        cout << male[N] << " " << total[N] + 1 << endl; 
        cin >> N;
    }

}
Leave a Comment