zoukankan      html  css  js  c++  java
  • Codeforces 702 D Road to Post Office

    题目描述

    Vasiliy has a car and he wants to get from home to the post office. The distance which he needs to pass equals to ddkilometers.

    Vasiliy's car is not new — it breaks after driven every kk kilometers and Vasiliy needs tt seconds to repair it. After repairing his car Vasiliy can drive again (but after kk kilometers it will break again, and so on). In the beginning of the trip the car is just from repair station.

    To drive one kilometer on car Vasiliy spends aa seconds, to walk one kilometer on foot he needs bb seconds ( a<ba<b ).

    Your task is to find minimal time after which Vasiliy will be able to reach the post office. Consider that in every moment of time Vasiliy can left his car and start to go on foot.

    输入输出格式

    输入格式:

    The first line contains 5 positive integers d,k,a,b,td,k,a,b,t ( 1<=d<=10^{12}1<=d<=1012 ; 1<=k,a,b,t<=10^{6}1<=k,a,b,t<=106 ; a<ba<b ), where:

    • dd — the distance from home to the post office;

    • kk — the distance, which car is able to drive before breaking;

    • aa — the time, which Vasiliy spends to drive 1 kilometer on his car;

    • bb — the time, which Vasiliy spends to walk 1 kilometer on foot;

    • tt — the time, which Vasiliy spends to repair his car.

    输出格式:

    Print the minimal time after which Vasiliy will be able to reach the post office.

    输入输出样例

    输入样例#1: 
    5 2 1 4 10
    
    输出样例#1: 
    14
    
    输入样例#2: 
    5 2 1 4 5
    
    输出样例#2: 
    13
    

    说明

    In the first example Vasiliy needs to drive the first 2 kilometers on the car (in 2 seconds) and then to walk on foot 3 kilometers (in 12 seconds). So the answer equals to 14 seconds.

    In the second example Vasiliy needs to drive the first 2 kilometers on the car (in 2 seconds), then repair his car (in 5 seconds) and drive 2 kilometers more on the car (in 2 seconds). After that he needs to walk on foot 1 kilometer (in 4 seconds). So the answer equals to 13 seconds.

    小学数学题。。。

    #include<iostream>
    #include<cstdio>
    #include<algorithm>
    #include<cstdlib>
    #include<cstring>
    #include<cmath>
    #include<vector>
    #define ll long long
    using namespace std;
    ll cost,d,b,a,k,t,n;
    int main(){
        scanf("%lld%lld%lld%lld%lld",&d,&k,&a,&b,&t);
        ll xl=(a-b)*k+t,tim=d/k+(d%k?1:0);
        cost=min(b*d,d*a+(tim-1)*t);
    
        if(k<=d){
            if(xl>0) cost=min(cost,b*d-t+xl);
            else{
                n=d/k;
                cost=min(cost,xl*n+b*d-t);
            }
        }
        
        printf("%lld
    ",cost);
        return 0;
    }
  • 相关阅读:
    用Webshell直接杀入内网
    别再说找不到Python练手项目了,这80个拿去过冬
    亲爱的,我是一条Linux运维技术学习路径呀。
    一份C++学习资源,咬牙切齿地好用呀
    技术变现,到底怎么变?本文或能成为你的“点金石”
    40个大数据学习资源,个个是干货,最后7个太给力
    零基础如何学好数据分析?
    8个程序员专用软件/网站,个个是神器,第一个最惊喜......
    如何写一个优秀的GitHub项目README文档?
    超全PHP学习资源整理:入门到进阶系列
  • 原文地址:https://www.cnblogs.com/JYYHH/p/8393386.html
Copyright © 2011-2022 走看看