Codechef November Challenge 2013 Missing some chairs
Missing some chairsProblem code: MCHAIRS |
Read problems statements in Mandarin Chinese and Russian.
A new school in Byteland is now in the process of renewing some classrooms with new, stronger and better chairs, so that the students can stay still and pay attention to class :)
However, due to budget and logistic reasons, it's only possible to carry a chair at a time to the classroom, which means that for a long time, many students will be up, waiting for their chair to arrive.
The teacher, however, as she is very clever, decided to challenge her students with a problem: "Imagine that there are N students in the classroom and that there are only K chairs. In how many ways, can I choose K elements from the class to sit down, if I see them as being distinct?"
Lira replied immediately with the right answer, so, the teacher decided to make the game a little funnier: "Okay Lira, as you are so fast, now I want you to tell me exactly the same thing, but, with the addition that the value of K is changing, this is, I want you to tell me the sum of the number of ways I can sit down K of you, if the value of K goes from 1 (meaning that there are no chairs in the classroom but one) to N (meaning that all of your chairs arrived). Can you be as fast now? As the answer might get large I want you to tell me the result modulo 1000000007. (109 + 7)"
As you might have noticed, it's time for you to help Lira solving this variant of the problem. :D
Input
The first line of the input file contains an integer T, denoting the number of test cases on the input file.
Afterwards, T lines follow, each containing an integer N, the number of students that the teacher will try to sit down as the number of chairs goes from 1 to N.
Output
For each test case, you should output an integer, denoting the sum of the number of ways the teacher can make N students sit down on K chairs, as K goes from 1 to N, modulo 109 + 7.
Constraints
- 1 ≤ T ≤ 100
- 1 ≤ N ≤ 100000000
Example
Input: 2 1 2 Output: 1 3
1 #pragma comment(linker, "/STACK:1024000000,1024000000") 2 #include <map> 3 #include <queue> 4 #include <vector> 5 #include <string> 6 #include <cmath> 7 #include <cstdio> 8 #include <cstring> 9 #include <cstdlib> 10 #include <iostream> 11 #include <algorithm> 12 using namespace std; 13 #define maxn 5005 14 #define ll long long 15 #define mod 1000000007 16 #define INF 0x7fffffff 17 #define eps 1e-8 18 int n,m; 19 int a[maxn]; 20 ll Pow(ll a, ll b){ 21 ll res = 1; 22 while (b){ 23 if(b&1)res = res*a%mod; 24 a = a*a%mod; 25 b >>= 1; 26 } 27 return res; 28 } 29 int main(){ 30 int t; 31 scanf("%d", &t); 32 while (t--){ 33 scanf("%I64d", &n); 34 m=Pow(2,n)-1; 35 printf("%I64d\n", m); 36 } 37 return 0; 38 }
浙公网安备 33010602011771号