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;
}
时间: 2024-08-22 18:02:08

ural 1113,jeep problem的相关文章

URAL 1881 Long problem statement

1881. Long problem statement Time limit: 0.5 secondMemory limit: 64 MB While Fedya was writing the statement of the problem GOV Chronicles, he realized that there might be not enough paper to print the statements. He also discovered that his text edi

Petrozavodsk Winter-2013. Ural FU Contest Problem D. Five Palindromes manacher、一个串切割成5个回文子串、优化

Ural Federal University Contest, SKB Kontur Cup Petrozavodsk Winter Training Camp, Saturday, February 2, 2013 Problem D. Five Palindromes Input file: input.txt Output file: output.txt Time limit: 2 seconds (3 seconds for Java) Memory limit: 256 mebib

URAL 1000 A+B Problem

Ural使用java7 只能用默认包 类名可以不是Main 1 import java.util.Scanner; 2   3 public class P1000 4 { 5     public static void main(String[] args) 6     { 7         try (Scanner cin = new Scanner(System.in)) 8         { 9             System.out.println(cin.nextInt(

HDU 1113 Word Amalgamation (map 容器 + string容器)

http://acm.hdu.edu.cn/showproblem.php?pid=1113 Problem Description In millions of newspapers across the United States there is a word game called Jumble. The object of this game is to solve a riddle, but in order to find the letters that appear in th

ural 1272. Non-Yekaterinburg Subway

1272. Non-Yekaterinburg Subway Time limit: 1.0 secondMemory limit: 64 MB A little town started to construct a subway. The peculiarity of the town is that it is located on small islands, some of them are connected with tunnels or bridges. The mayor is

ural 1273. Tie

1273. Tie Time limit: 1.0 secondMemory limit: 64 MB The subway constructors are not angels. The work under the ground and… Well, they are not angels. And where have you seen angels? It is all in a lifetime! Show me first somebody who has never… and t

ural 1269. Obscene Words Filter

1269. Obscene Words Filter Time limit: 0.5 secondMemory limit: 8 MB There is a problem to check messages of web-board visitors for the obscene words. Your elder colleagues commit this problem to you. You are to write a program, which check if there i

ural 1218. Episode N-th: The Jedi Tournament

1218. Episode N-th: The Jedi Tournament Time limit: 1.0 secondMemory limit: 64 MB Decided several Jedi Knights to organize a tournament once. To know, accumulates who the largest amount of Force. Brought each Jedi his lightsaber with him to the tourn

ural 1217. Unlucky Tickets

1217. Unlucky Tickets Time limit: 1.0 secondMemory limit: 64 MB Strange people live in Moscow! Each time in the bus, getting a ticket with a 6-digit number, they try to sum up the first half of digits and the last half of digits. If these two sums ar