Cod sursă (job #465290)

Utilizator avatar DimaTC grelype DimaTC IP ascuns
Problemă SCV (clasele 9-10) Compilator cpp | 0,56 kb
Rundă lasm_31_03_2019_10_12 Status evaluat
Dată 2 apr. 2019 17:58:08 Scor 100
#include<bits/stdc++.h>

using namespace std;


int c,t,m,x,k,nr,n,rs;

int main() {
    ifstream cin("scv.in");
    ofstream cout("scv.out");
    cin>>c>>t>>m>>x; k=1;

    while (nr<x) {
        while (nr<c && nr<x) {
            ++rs; nr+=m*k;
        }
        if (nr>=x) break;

        int tmp=nr+m*k*t+m*k*(c/m);
        if (tmp<x) {
            rs+=t;
            nr=nr-c+m*t*k;
            ++k;
        } else {
            while (nr<x) {
                ++rs; nr+=m*k;
            }
        }
    }
    cout<<rs;

    return 0;
}