http://acm.hdu.edu.cn/showproblem.php?pid=5363

Key Set

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

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
 

int Pow(int a, int b)
{
int ans = 1;
while(b)
{
if(b % 2 == 1)
ans *= a;
a *= a;
b /= 2;
}
return ans;
}//快数幂,求a的b次幂

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
#define N 500 long long Pow(long long a, long long b, long long c)
{
long long ans = ;
a %= c;
while(b)
{
if(b % == )
ans = (ans * a) % c;
a = (a * a) % c;
b /= ;
}
return ans;
}//快数幂,求a的b次幂,c表示对c取余 int main()
{
int t;
long long n, num;
scanf("%d", &t);
while(t--)
{
scanf("%lld", &n);
num = Pow(, n - , );
printf("%lld\n", num - );
}
return ;
}

hdu 5363 Key Set的更多相关文章

  1. 2015 HDU 多校联赛 5363 Key Set

    2015 HDU 多校联赛 5363 Key Set 题目: http://acm.hdu.edu.cn/showproblem.php? pid=5363 依据前面给出的样例,得出求解公式 fn = ...

  2. HDU 3313 Key Vertex(dfs + bfs)

    HDU 3313 Key Vertex 题目链接 题意:一个有向无环图.求s,t之间的割点 思路:先spfa找一条最短路出来,假设不存在.就n个都是割点. 然后每次从s进行dfs,找到能经过最短路上的 ...

  3. 【HDU 5363】Key Set

    题 Description soda has a set $S$ with $n$ integers $\{1, 2, \dots, n\}$. A set is called key set if ...

  4. 【HDU 5363】Key Set(和为偶数的子集个数)

    题 Description soda has a set $S$ with $n$ integers $\{1, 2, \dots, n\}$. A set is called key set if ...

  5. Key Set HDU - 5363

    这个题目套公式 2^(n-1)-1,再来个快速幂基本上就可以AC了 写这个题目的: 公式容易推到错: 容易写成 2^n-1/2...这样写出来结果也不错  但是一直哇 AC: #include< ...

  6. hdu 1885 Key Task

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1885 Key Task Description The Czech Technical Univers ...

  7. hdu 1885 Key Task(bfs+位运算)

    题意:矩阵中'#'表示墙,'.'表示通路,要求从起点'*'到达终点'X',途中可能遇到一些门(大写字母),要想经过,必须有对应的钥匙(小写字母).问能否完成,若能,花费的时间是多少. 分析:同hdu ...

  8. hdu 1885 Key Task (三维bfs)

    题目 之前比赛的一个题, 当时是崔老师做的,今天我自己做了一下.... 还要注意用bfs的时候  有时候并不是最先到达的就是答案,比如HDU 3442 这道题是要求最小的消耗血量伤害,但是并不是最先到 ...

  9. HDU 1885 Key Task(三维BFS)

    题目链接 题意 : 出口不止一个,一共有四种颜色不同的门由大写字母表示,而钥匙则是对应的小写字母,当你走到门前边的位置时,如果你已经走过相应的钥匙的位置这个门就可以走,只要获得一把钥匙就可以开所有同颜 ...

随机推荐

  1. 面试题_31_to_47_JVM 底层与GC(Garbage Collection)的面试问题

    31)64 位 JVM 中,int 的长度是多数?Java 中,int 类型变量的长度是一个固定值,与平台无关,都是 32 位.意思就是说,在 32 位 和 64 位 的Java 虚拟机中,int 类 ...

  2. 海量WEB日志分析

    Hadoop家族系列文章,主要介绍Hadoop家族产品,常用的项目包括Hadoop, Hive, Pig, HBase, Sqoop, Mahout, Zookeeper, Avro, Ambari, ...

  3. DirectSound播放PCM(可播放实时采集的音频数据)

    前言 该篇整理的原始来源为http://blog.csdn.net/leixiaohua1020/article/details/40540147.非常感谢该博主的无私奉献,写了不少关于不同多媒体库的 ...

  4. android完全退出应用程序

    android 完全退出应用程序android android 退出应用程序, 单例模式管理Activity引自:http://www.yoyong.com/archives/199android 退 ...

  5. Hibernate学习笔记之EHCache的配置

    Hibernate默认二级缓存是不启动的,启动二级缓存(以EHCache为例)需要以下步骤: 1.添加相关的包: Ehcache.jar和commons-logging.jar,如果hibernate ...

  6. hMailserver设置外部反病毒扫描程序

    刚在5dmail上发现有人提出一个问题,他在hmailserver的外部病毒扫描程序中使用了瑞星那个娱乐货,结果呢,说瑞星太勇猛了,所有附件都认为病毒了,这是怎么个情况呢? 先从hmailadmin里 ...

  7. POJ 1664 放苹果

    放苹果 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24985   Accepted: 15908 Description ...

  8. Autofac 依赖注入 ASP.NET MVC5 插件机制中插件的简单实现

    一.前言 由于项目业务复杂,创建了多个插件并把他们放在了不同的项目中,项目使用AutoFac做的IOC:但是主项目可以注入,插件注入失败, 没有为该对象定义无参数的构造函数.下面就一步一步注入插件项目 ...

  9. Github 终于开始认真考虑开源项目许可证了

    如今GitHub已成为全球最流行的开源项目托管平台,但也有质疑声音——“Github中的大多数项目并不算是开源项目”.这是因为Github中大多数项目并没有明确声明所使用的许可证. 根据版权法规定,如 ...

  10. [转] 使用C#开发ActiveX控件

    双魂人生 原文 使用C#开发ActiveX控件 ActiveX 是一个开放的集成平台,为开发人员.用户和 Web生产商提供了一个快速而简便的在 Internet 和 Intranet 创建程序集成和内 ...