ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1113. Jeep

Where is mistake?
Posted by Drema [KhAI] Tihov Ilya 11 Jun 2009 14:20
#include <iostream>
#include <stdlib.h>
using namespace std;

int main()
{
    int m, n, f;
    double out;
    div_t o;
    double way[32005] = {0};
    long long int oil[32005] = {0};

    cin >> n >> m;
    way[1] = m;
    oil[1] = m;

    for(f = 1; way[f - 1] + m / (2 * f - 1) < n; f++)
    {
        way[f] = way[f - 1] + m / (2 * f - 1);
        oil[f] = f * m;
    }

    out = (n - way[f - 1]) * (2 * f - 1) + oil[f - 1];
    o = div(out, 1);

    if(abs(out - o.quot) < 1e-8)
        cout << o.quot;
    else
        cout << o.quot + 1;

}