DieDie
Practice
4.2 (57 votes)
Approved
Combinatorics
Easy
Exception handling
Math
Number theory
Open
Probability
Statistics
Problem
55% Success 4186 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

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

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
52 votes
Tags:
Basic ProgrammingNumber theoryBasic Number Theory-1MathNumber Theory
Points:30
24 votes
Tags:
AlgorithmsApprovedEasyOpen
Points:30
29 votes
Tags:
ApprovedEasyMathNumber theory