messed-up-rugby.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/python
  2. # Memory Limit:1024 MB
  3. # Time Limit: 5 s
  4. # Messed up Rugby (100 points)
  5. # Introduction
  6. # A team of developers from New York visits London and decides to try their hands at Rugby. None of
  7. # them quite remember the exact rules so they just use the rules of American Football where you can
  8. # score 2, 3 or 7 points at a time.
  9. # When they talk to you afterwards, they tell you that the final score of the game was 38 - 0. After
  10. # facepalming, you are curious to find all possible ways to score 38 points.
  11. # Write a program that, given a score X, prints all possible combinations of the messed up conversions
  12. # (7 points), tries (3 points), and kicks (2 points) that would make up this score.
  13. # Input Specifications
  14. # Your program will take a target score between 0 and 222.
  15. # Output Specifications
  16. # Based on the input, print out one row for each combination of messed up conversions, tries, and kicks
  17. # that would get to that score, each column delimited by a space. The output should be in ascending
  18. # order of touchdowns, field goals, and then safeties. If the score is not achievable, just output 0 0 0
  19. # Sample Input/Output
  20. # Input
  21. # 10
  22. # Output
  23. # 0 0 5
  24. # 0 2 2
  25. # 1 1 0
  26. # Explanation
  27. # There are three possible ways to reach a score of 10 given the rules above.
  28. # Input
  29. # 17
  30. # Output
  31. # 0 1 7
  32. # 0 3 4
  33. # 0 5 1
  34. # 1 0 5
  35. # 1 2 2
  36. # 2 1 0
  37. # Explanation
  38. # There are six possible ways to reach a score of 10 given the rules above.
  39. from __future__ import print_function
  40. import sys
  41. data = sys.stdin.readlines()
  42. print(data)