多校6 1011 Key Set

Key Set

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 1476    Accepted Submission(s): 726

Problem Description

soda has a set S with n integers {1,2,…,n}. A set is called key set if the sum of integers in the set is an even number. He wants to know how many nonempty subsets of S are key set.

Input

There are multiple test cases. The first line of input contains an integer T (1≤T≤105), indicating the number of test cases. For each test case:

The first line contains an integer n (1≤n≤109), the number of integers in the set.

Output

For each test case, output the number of key sets modulo 1000000007.

Sample Input

4
1
2
3
4

Sample Output

0
1
3
7

 1 #include <stdio.h>
 2 #include <string.h>
 3 using namespace std;
 4 long long mod=1000000007;
 5
 6 long long pow_mod(long long x, long long n)    {
 7     long long res = 1;
 8     while (n)    {
 9         if (n & 1)    res = res * x % mod;
10         x = x * x % mod;
11         n >>= 1;
12     }
13     return res;
14 }
15
16 int main()
17 {
18     int T;
19     long long n;
20     scanf("%d",&T);
21     while(T--)
22     {
23         scanf("%I64d",&n);
24         printf ("%I64d\n", pow_mod (2, n - 1) - 1);
25     }
26     return 0;
27 }

时间: 2024-11-03 21:13:13

多校6 1011 Key Set的相关文章

2014 (多校)1011 ZCC Loves Codefires

自从做了多校,整个人都不好了,老是被高中生就算了,题老是都不懂=-=原谅我是个菜鸟,原谅我智力不行.唯一的水题. Problem Description Though ZCC has many Fans, ZCC himself is a crazy Fan of a coder, called "Memset137". It was on Codefires(CF), an online competitive programming site, that ZCC knew Mems

2015 HDU 多校联赛 5363 Key Set

2015 HDU 多校联赛 5363 Key Set 题目: http://acm.hdu.edu.cn/showproblem.php?pid=5363 根据前面给出的例子,得出求解公式 fn = 2^(n-1) - 1, 数据量大,实际就是求幂次方. 可用分治法求解,复杂度O(nlogn) // 分治法求快速幂 #include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; const int MO

HDU 4970(杭电多校#9 1011题)Killing Monsters(瞎搞)

题目地址:HDU 4970 先进行预处理,在每个炮塔的火力范围边界标记一个点.然后对每个点的伤害值扫一遍就能算出来.然后在算出每个点到终点的总伤害值,并保存下来,也是扫一遍即可.最后在询问的时候直接判断即可,复杂度O(2*n). 代码如下: #include <cstdio> #include <cstring> #include <algorithm> using namespace std; #define maxn 110000 #define LL __int6

多校3 1011 Work

Work Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 230    Accepted Submission(s): 171 Problem Description It’s an interesting experience to move from ICPC to work, end my college life and star

2019杭电多校十 1011 Make Rounddog Happy(rmq + 分治)

题意 有一个大小为 \(n ,(n \leq 3e5)\) 的序列,序列中的每一个数 \(a_i\) 满足\(1 \leq a_i \leq n\), 现定义 good subarray:对于一段区间\(a_l, a_{l+1}, \dots, a_r\),满足区间内无重复元素并且 \(\max\{a_l, a_{l+1}, \dots, a_r\} - (r-l+1) \leq k\). 求序列a中的 good subarray的数量. 思路 rmq + 分治的套路题. 针对最大值,可通过rm

多校题解

##[1001.Average](http://acm.hdu.edu.cn/showproblem.php?pid=5353) Summary $n$ people are sitting around a circle and every two adjacent people can exchange only on candy. The goal is to find a valid exchange order to make everyone have equal amount of

hdu4970 Killing Monsters (差分数列)

2014多校9 1011 http://acm.hdu.edu.cn/showproblem.php?pid=4970 Killing Monsters Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 331    Accepted Submission(s): 198 Problem Description Kingdom Rush

Haproxy Configure File

---------------------- HAProxy Configuration Manual ---------------------- version 1.5.11 willy tarreau 2015/02/01 This document covers the configuration language as implemented in the versionspecified above. It does not provide any hint, example or

hdu5379||2015多校联合第7场1011 树形统计

http://acm.hdu.edu.cn/showproblem.php? pid=5379 Problem Description Little sun is an artist. Today he is playing mahjong alone. He suddenly feels that the tree in the yard doesn't look good. So he wants to decorate the tree.(The tree has n vertexs, i