Пожалуйста, подпишитесь на официальный канал Codeforces в Telegram по ссылке https://t.me/codeforces_official. ×

Question on Numeric Key Pad. Help me to optimize my code and logic. Recursion.

Правка en2, от Aman_dixit, 2021-04-27 10:41:23

Here is the question.

================== Given the mobile numeric keypad. You can only press buttons that are up, left, right or down to the current button. You are not allowed to press bottom row corner buttons (i.e. * and # ). You have to find the count of different numbers that can be generated by pressing N number of buttons.

[https://pastebin.com/keTA6d4J] Here is my code. I am getting wrong ans for n=3 . the ans is 138 and i am getting 112. Please help me to figure out what i have missed in my logic.

Теги #recursion,dp

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский Aman_dixit 2021-04-27 10:47:22 22
en2 Английский Aman_dixit 2021-04-27 10:41:23 27
en1 Английский Aman_dixit 2021-04-27 10:38:49 577 Initial revision (published)