Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Softuniada 2019
- Digitivision
- You will be given 3 digits. Your task is to find if there is any 3-digit number:
- • Formed by the given digits
- • That is divisible (without remainder) by the sum of the given digits
- If there is any number fulfilling the conditions specified above, you should print "Digitivision successful!".
- If there is no such number, you should print "No digitivision possible.".
- Input
- The input comes in 3 input lines, each of them containing a single digit.
- Output
- Depending on whether a "digitivision" is possible or not you should print one of the following lines:
- • "Digitivision successful!", if there is a successful "digitivision" without remainder.
- • "No digitivision possible.", if there is no possible "digitivision" without remainder.
- Constraints
- • The input lines will contain only digits – integers in range [0, 9].
- • Allowed time / memory: 100ms / 16MB.
- input: 6
- input: 2
- input: 1
- Output: "Digitivision successful!"
- The sum of the digits is 9. We start forming the numbers:
- 621 / 9 = 69
- 612 / 9 = 68
- 261 / 9 = 29
- 216 / 9 = 24
- 162 / 9 = 18
- 126 / 9 = 14
- There are 6 possible divisions without remainder.
- We needed only 1. Hence, the "digitivision" is possible.
- input: 3
- input: 3
- input: 4
- Output: "No digitivision possible."
- The sum of the digits is 10. We start forming the numbers:
- 334 / 10 = 33.4 (remainder 0.4)
- 343 / 10 = 34.3 (remainder 0.3)
- 433 / 10 = 43.3 (remainder 0.3)
- There are no possible divisions without remainder.
- Hence, the "digitivision" is NOT possible.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement