Advertisement
Guest User

Softuniada - 1

a guest
Feb 23rd, 2020
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. Softuniada 2019
  2.  
  3. Digitivision
  4. You will be given 3 digits. Your task is to find if there is any 3-digit number:
  5. • Formed by the given digits
  6. • That is divisible (without remainder) by the sum of the given digits
  7. If there is any number fulfilling the conditions specified above, you should print "Digitivision successful!".
  8. If there is no such number, you should print "No digitivision possible.".
  9. Input
  10. The input comes in 3 input lines, each of them containing a single digit.
  11. Output
  12. Depending on whether a "digitivision" is possible or not you should print one of the following lines:
  13. • "Digitivision successful!", if there is a successful "digitivision" without remainder.
  14. • "No digitivision possible.", if there is no possible "digitivision" without remainder.
  15. Constraints
  16. • The input lines will contain only digits – integers in range [0, 9].
  17. • Allowed time / memory: 100ms / 16MB.
  18. input: 6
  19. input: 2
  20. input: 1
  21. Output: "Digitivision successful!"
  22. The sum of the digits is 9. We start forming the numbers:
  23. 621 / 9 = 69
  24. 612 / 9 = 68
  25. 261 / 9 = 29
  26. 216 / 9 = 24
  27. 162 / 9 = 18
  28. 126 / 9 = 14
  29. There are 6 possible divisions without remainder.
  30. We needed only 1. Hence, the "digitivision" is possible.
  31.  
  32. input: 3
  33. input: 3
  34. input: 4
  35. Output: "No digitivision possible."
  36. The sum of the digits is 10. We start forming the numbers:
  37. 334 / 10 = 33.4 (remainder 0.4)
  38. 343 / 10 = 34.3 (remainder 0.3)
  39. 433 / 10 = 43.3 (remainder 0.3)
  40. There are no possible divisions without remainder.
  41. Hence, the "digitivision" is NOT possible.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement