Skip to content

BruceTrindade/RoadTrip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RoadTrip

The invention of the car made it much faster and cheaper to travel long distances. Carrying out a road trip has two types of costs: each kilometer traveled on the highway has an associated cost (not only due to fuel consumption but also due to the wear of car parts, tires, etc.), but it is also necessary to go through several tolls located along the highway.

Tolls are evenly spaced along the highway; the beginning of the road does not have a toll, but its end may be right after a toll (for example, if the distance between two consecutive tolls is 37 km and the road is 111 km, the driver must pay a toll at 37 km , at 74 km and at 111 km, just before finishing your trip)

Assignment Given the characteristics of the highway and the cost of gasoline and tolls, calculate the total cost of the trip.

Input The input consists of two lines. The first line of the input contains two integers L and D (1 ≤ L, D ≤ 104), indicating the length of the road and the distance between tolls, respectively. The second line contains two integers K and P (1 ≤ K, P ≤ 10 4 ), indicating the cost per kilometer traveled and the value of each toll. The first toll booth is located at kilometer D of the road (ie the distance from the start of the road to the first toll is D kilometers).

Exit Your program should print a single line containing a single integer indicating the total cost of the trip.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages