Spocoman

Bike Race

Jan 5th, 2022 (edited)
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. junior = int(input())
  2. senior = int(input())
  3. trace = input()
  4. junior_sum = 0
  5. senior_sum = 0
  6.  
  7. if trace == 'trail':
  8.     junior_sum = 5.5
  9.     senior_sum = 7
  10. elif trace == 'cross-country':
  11.     junior_sum = 8
  12.     senior_sum = 9.5
  13. elif trace == 'downhill':
  14.     junior_sum = 12.25
  15.     senior_sum = 13.75
  16. elif trace == 'road':
  17.     junior_sum = 20
  18.     senior_sum = 21.5
  19.  
  20. total = junior * junior_sum + senior * senior_sum
  21.  
  22. if trace == 'cross-country' and (junior + senior) >= 50:
  23.     total *= 0.75
  24.  
  25. print(f'{total * 0.95:.2f}')
  26.  
  27.  
  28. Фундаменталс решение:
  29.  
  30. junior = int(input())
  31. senior = int(input())
  32. trace = input()
  33.  
  34. total = sum({'trail': {junior * 5.5, senior * 7},
  35.              'cross-country': {junior * 8, senior * 9.5},
  36.              'downhill': {junior * 12.25, senior * 13.75},
  37.              'road': {junior * 20, senior * 21.5}}[trace])
  38.  
  39. if trace == 'cross-country' and (junior + senior) >= 50:
  40.     total *= 0.75
  41.  
  42. print(f'{total * 0.95:.2f}')
  43.  
  44.  
Add Comment
Please, Sign In to add comment