Skip to main content

TCS

TCS OA-2 2024

Problem Description


You are tasked with writing a program to calculate the total shipping cost based on the weight of the package and the distance it needs to travel. The following criteria determine the shipping cost:

1. Base money: $5.00 (must be included in the shipping cost)

2. Cost per kilogram: $2.00

3. Cost per 10 kilometers: $0.5

Input Format

  • The first line contains an integer w, representing the weight of the package.
  • The second line contains an integer d, representing the distance it needs to travel.

Output Format

Print the total shipping cost of the package.

Constraints

  • 1 ≤ w ≤ 10⁷
  • 1 ≤ d ≤ 10⁷

Example

Sample Input:

20
200

Sample Output:

55

Explanation:

The base cost is 5, which must be included.
Given a weight of 20 kg and a rate of 2 per kilogram, the weight cost is calculated as 20×2=40.
For a distance of 200 km, with a rate of 0.5 per 10 km, the distance cost is 200×0.5/10=10.
Therefore, the total cost is 5+40+10=55.