#136EasyOperators· Integer Arithmetic

Split the Bill

Friends split a restaurant bill, including a tip, and nobody wants to lose a cent to rounding. Work in whole cents. Write `split_bill(total_cents, people, tip_percent)`: 1. The tip is `total_cents * tip_percent // 100` cents (rounded down). 2. The amount to collect is the bill plus the tip. 3. Everyone pays the same whole number of cents, and the cents that are left over are paid one each by the first people in the list. Return a list with each person's share formatted as dollars and cents, for example `"12.05"`.

Input format

`total_cents`: the bill in cents. `people`: how many people share it. `tip_percent`: a whole-number percentage.

Output format

A list of `people` strings, each with exactly two digits after the dot.

Examples

Input: total_cents = 10000, people = 3, tip_percent = 15
Output: ["38.34","38.33","38.33"]
The tip is 1500, so 11500 cents are split three ways: 3833 each with 1 cent left over for the first person.
Input: total_cents = 999, people = 1, tip_percent = 0
Output: ["9.99"]
One person pays everything.

Constraints

  • 0 <= total_cents <= 10^7
  • 1 <= people <= 50
  • 0 <= tip_percent <= 100

Study first

  • #python
  • #operators
  • #integer-arithmetic
  • #money