标签:
题目链接: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; }
标签:
原文地址:http://www.cnblogs.com/TreeDream/p/5898407.html