Advertisement
ZRE0412

Untitled

Nov 24th, 2022
451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. import math
  2.  
  3. people = int(input())
  4. infectPeople = int(input())
  5. recoveryDay = int(input())
  6. protectedRate = float(input())
  7. periodWeek = int(input())
  8. waitRecovery = [0]*recoveryDay + [people]
  9. target = float('inf')
  10.  
  11. for i in range(periodWeek):
  12.     thisWeekInfect, thisWeekNewInfect, thisWeekRecovery = 0, 0, 0
  13.     for j in range(7):
  14.         if i == 0 and j == 0:
  15.             thisWeekNewInfect += people
  16.             thisWeekInfect += people
  17.             continue
  18.         waitRecovery.append(int(people*(infectPeople/recoveryDay)*(1-protectedRate)))
  19.         people = people + waitRecovery[-1] - waitRecovery[i*7+j]
  20.         thisWeekNewInfect += waitRecovery[-1]
  21.         thisWeekInfect += people
  22.         thisWeekRecovery += waitRecovery[i*7+j]
  23.     averageWeekNewInfect = math.ceil(thisWeekNewInfect/7)
  24.     print(f'(Week {i+1}, {math.ceil(thisWeekInfect/7)}, {averageWeekNewInfect}, {math.ceil(thisWeekRecovery/7)})')
  25.     if averageWeekNewInfect == 0:
  26.         target = min(target, i+1)
  27.  
  28. print(target)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement