Cod sursă (job #764326)

Utilizator avatar headcrab694 Turcanu Adrian headcrab694 IP ascuns
Problemă SCV (clasele 9-10) Compilator cpp-32 | 0,64 kb
Rundă lasm_22_02_2024_clasa12 Status evaluat
Dată 22 feb. 2024 13:15:01 Scor 0
#include <bits/stdc++.h>
using namespace std;

int main() {
    int C, T, M, X;
    // Read input from the file scv.in
    ifstream fin("scv.in");
    fin >> C >> T >> M >> X;

    int days = 0;
    int minerals_collected = 0;
    int scvs = 1;

    while (minerals_collected < X) {
        days++;
        minerals_collected += scvs * M;

        if (minerals_collected >= C) {
            int new_scvs = minerals_collected / C;
            scvs += new_scvs;
            minerals_collected -= new_scvs * C;
            days += T;
        }
    }

	
    ofsteam fout("scv.out");
    fout << days << endl;

    return 0;
}