Cod sursa(job #1994532)

Utilizator PopoviciRobertPopovici Robert PopoviciRobert Data 25 iunie 2017 10:48:12
Problema Progresii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.74 kb
#include <bits/stdc++.h>
#define MAXN 100001

const double eps = 1e-7;

double t[MAXN + 1];
double p[MAXN + 1];

int main() {
    std::ifstream cin("progresii.in");
    std::ofstream cout("progresii.out");
    int i, n;
    double m, l, k;
    std::ios::sync_with_stdio(false);
    cin >> n >> m >> k >> l;
    for(i = 1; i <= n; i++) {
        cin >> p[i];
        p[i]--;
    }
    for(i = n; i >= 1; i--)
        t[i] = t[i + 1] + (l - p[i]) / m;
    for(i = 1; i <= n; i++) {
        double x = (l - p[i]) / (k - t[i + 1]);
        if(x - floor(x) > eps)
            x = floor(x) + 1;
        k -= (int) ((l - p[i]) / x);
        cout << (int) x << std::endl;
    }
    cin.close();
    cout.close();
    return 0;
}