Connection Status:
Competition Arena > BritishCoins
SRM 165 · 2003-09-23 · by vorthys · Simple Math
Class Name: BritishCoins
Return Type: int[]
Method Name: coins
Arg Types: (int)
Problem Statement

Problem Statement

Prior to 1971, Britain used a system of coins that can be traced back to the time of Charlemagne. The three main units of coinage were the penny, the shilling, and the pound. There were 12 pennies in a shilling and 20 shillings in a pound. Given a number pence of pennies, convert this amount into pounds, shillings, and pennies by first converting as many pennies as possible into pounds, and then converting as many of the remaining pennies as possible into shillings. Return a int[] of size three containing the number of pounds, the number of shillings, and the number of pennies, in that order.

Constraints

  • pence is between 0 and 10000, inclusive.
Examples
0)
533
Returns: { 2,
  4,
  5 }

First, we make 2 pounds, leaving 53 pence. Then, we make 4 shillings, leaving 5 pence.

1)
0
Returns: { 0,
  0,
  0 }
2)
6
Returns: { 0,
  0,
  6 }
3)
4091
Returns: { 17,
  0,
  11 }
4)
10000
Returns: { 41,
  13,
  4 }

Submissions are judged against all 57 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class BritishCoins with a public method vector<int> coins(int pence) · 57 test cases · 2 s / 256 MB per case

Submitting as anonymous