All Tracks Math Number Theory Basic Number Theory-1 Problem

DieDie
Tag(s):

Combinatorics, Easy-Medium, Exception handling, Mathematics, Number Theory, Probability and Statistics

Problem
Editorial
Analytics

Link to Russian translation of problem

There are N ants staying at the vertices of the N-regular polygon (one ant at one vertex). At some moment of time all the ants choose one of the edges their vertex is adjacent to and start walking along this edge. If two ants meet at some point of the edge they die. Please find the probability that all the ants will survive.

Input
The first line contains one integer T - number of test cases. The following T lines contain one integer each - N.

Output
We can consider answer as a fraction P / Q. For each test case output P * Q-1 modulo 109 + 7.

Constraints

  • T <= 1000
  • 3 <= N <= 1011
SAMPLE INPUT
1
3
SAMPLE OUTPUT
250000002
Time Limit: 1,0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

HackerEarth

Challenge Name

Code Monk (Number Theory - III)

OTHER PROBLEMS OF THIS CHALLENGE
Уведомления
View All Notifications

?