#K78687. Split the Trip Cost Evenly
Split the Trip Cost Evenly
Split the Trip Cost Evenly
Given the number of friends n and the total cost of the trip c (in dollars), the task is to split the cost evenly among all friends. Since the cost may not be divisible exactly, compute both the amount each friend must pay and the remaining cost that cannot be evenly split.
The division should follow the rules of integer division. Specifically, if each friend pays an equal share, then the amount each friend pays is \(\lfloor \frac{c}{n} \rfloor\) and the remainder is \(c \bmod n\).
The program will read from stdin a single line containing two space-separated positive integers: n and c, and will print to stdout two integers: the cost per friend and the remaining cost.
inputFormat
The input consists of a single line containing two space-separated positive integers: \(n\) (the number of friends) and \(c\) (the total trip cost in dollars).
Example: 4 100
outputFormat
Output two integers separated by a space. The first integer is the amount each friend needs to pay (using integer division), and the second integer is the remainder of the division.
Example: For the input 4 100
, the output should be 25 0
.
4 100
25 0
</p>