SHARE
TWEET

Untitled

a guest Jul 21st, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. A = int(input())
  2. B= int(input())
  3. f = [1,2]
  4. for i in range(3,A+1):
  5.     if B>0:
  6.         if i==3:
  7.             f.append(f[i-1]+f[i-2]+1)
  8.         else:
  9.             f.append(f[i-1]+f[i-2]+f[i-3])
  10.         B-=1
  11.     else:
  12.         f.append(f[i-1]+f[i-2])
  13. print(f[-1])
  14.  
  15.  
  16. Test case:
  17. A=4
  18. B=1
  19. Output expected=7
  20. I got 6
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top