Sherlock and Square

  • [deleted]
    + 1 comment

    can anyone tell me why am I getting termination due to timeout for the following code

    test = int(input())
    
    for i in range(test):
        num = int(input())
        answer = (2**(num+1)) + 2
        print(answer % 1000000007)
    

    is there a way to do it even faster

    • + 0 comments

      num can be as large as 10**9, think about taking power of a number in a fast way..