Cod sursă (job #764324)

Utilizator avatar headcrab694 Turcanu Adrian headcrab694 IP ascuns
Problemă SCV (clasele 9-10) Compilator cpp-32 | 0.69 kb
Rundă lasm_22_02_2024_clasa12 Status evaluat
Dată 22 feb. 2024 13:14:00 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;
        }
    }

    // Write output to the file scv.out
    ofstream fout("scv.out", "w", stdout);
    fout << days << endl;

    return 0;
}