//目录

ural 1113,jeep problem

题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1113

网上的解答铺天盖地。我硬是花了两天才懂了点。

wiki上的解释:https://en.wikipedia.org/wiki/Jeep_problem

 

解答:每个点的油量是500,500*2,500*3... ...

每次的距离是500,500/3,500/5,... ...,500/2n-1;

#include <bits/stdc++.h>
using namespace std;

int main()
{
    double dist, tank;
    scanf("%lf%lf", &dist, &tank);
    double now = dist, cost = 0, pre;
    int k = 1;
    while( (pre = now - tank / (2*k-1)) > 0){
        cost += tank;
        now = pre;
        k++;
    }
    cost += now * (2*k-1);
    printf("%.0f\n", ceil(cost));
    return 0;
}

 

posted @ 2016-09-22 23:45  小草的大树梦  阅读(227)  评论(0编辑  收藏  举报