题目链接: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;
}

 

相关文章:

  • 2021-09-08
  • 2021-05-25
  • 2021-06-21
  • 2022-01-19
  • 2022-03-08
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-08
  • 2021-07-12
  • 2021-05-22
  • 2021-08-16
  • 2021-08-01
  • 2021-10-02
  • 2021-11-15
相关资源
相似解决方案