Блог пользователя Optimal_Aces

Автор Optimal_Aces, история, 5 лет назад, По-английски

https://www.codechef.com/problems/CKISSHUG

My method :- if first place is H then there are 2^(n-1) possibilities if first place is K then there are 2^(n-1/2) possibilities but this method is not right .

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
5 лет назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

I fully solved it on Codechef.

The formula is { 2^(((n-1)/2)+2) -2 } + 2^(n/2) if n is even.

You have to calculate power of 2 using Modular Exponentiation. You can read it about here https://www.geeksforgeeks.org/modular-exponentiation-power-in-modular-arithmetic/

This is my code https://www.codechef.com/viewsolution/26865644 Hope it helps :) Please upvote it if it helps.