Counting Swann's Coins
InterviewTime limit1sMemory limit128 MB
Print numbers 1 through N, replacing multiples of 3 with Dead, of 5 with Man, and of 15 with DeadMan, breaking the line after each word.
- Level
Easy2 of 10
- Topics
- Implementation, Math, Simulation
- Solved
- No attempts yet
Problem
Governor Weatherby Swann orders you to count the coins in the government treasury. To make the task less dull, you count out loud from up to the given number, replacing some numbers with words according to these rules:
- Say Dead for every multiple of .
- Say Man for every multiple of .
- Say DeadMan for every number that is a multiple of both and (that is, every multiple of ).
Every other number is said as its ordinary value.
Input
A single line containing one integer , the number of coins to count ().
Output
Print the counting sequence for . Ordinary numbers are separated by single spaces. A word (Dead, Man, or DeadMan) is always the last token on its line, so after saying a word you move to a new line. Every printed line ends with a newline character, including the final line even when it ends with an ordinary number because is not a multiple of or .