Advertisement
ZRE0412

Untitled

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