题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5363
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错了,索性全改为long long

 #include <iostream>
#include <cmath>
using namespace std; long long f(long long a)
{
long long temp=;
long long ans=;
while (a)
{
if (a%!=)
ans*=temp; ans=ans%;
temp=temp*temp;
temp=temp%;
a/=;
}
return ans;
}
int main()
{
long long n,m;
cin>>n;
while (n--)
{
cin>>m;
cout <<f(m-)-<<endl;
}
return ;
}

hdu 5363Key Set的更多相关文章

  1. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  2. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  3. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  4. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  5. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  6. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

  7. hdu 4481 Time travel(高斯求期望)(转)

    (转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...

  8. HDU 3791二叉搜索树解题(解题报告)

    1.题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=3791 2.参考解题 http://blog.csdn.net/u013447865/articl ...

  9. hdu 4329

    problem:http://acm.hdu.edu.cn/showproblem.php?pid=4329 题意:模拟  a.     p(r)=   R'/i   rel(r)=(1||0)  R ...

随机推荐

  1. Cisco Anyconnect Secure Mobility Client

    Backup 进入安装文件目录cd anyconnect-3.1.00495/binary 安装sudo./vpnsetup.sh 查看安装情况ps aux  |  grep  cisco 在搜索中, ...

  2. 一直想测试的NGINX变量输出,最于有办法了。

    参考URL: http://blog.ailms.me/2013/08/04/nginx-server_name-and-host-difference.html 要是可能在正则测试及REWRITE就 ...

  3. sp_xml_preparedocument _使用 处理XML文档

      有时会在存储过程中处理一些XML格式的数据,所以会用到sp_xml_preparedocument,他可以将XML数据进行读取,然后使用 MSXML 分析器 (Msxmlsql.dll) 对其进行 ...

  4. SSH自动部署(转)

    我的是windows环境,目前开发的过程中,有些项目需要一下子部署到很多的linux服务器上.写了个脚本能够自动上传文件和执行部署任务.完成这个任务需要的条件包括SSH配置和一个执行脚本. 准备 1. ...

  5. pywin32 安装错误 ImportError: DLL load failed: 不是有效的 Win32 应用程序

    pywin32 安装错误 ImportError: DLL load failed:  不是有效的 Win32 应用程序. 发现是因为没有制定Pywin32的dll所致,我们在用Pywin32开发时, ...

  6. 【 Failed to create the Java Virtual Machine】的2种解决方式

    初学Android,下载并安装好了eclipse,ADT和SDK之后,打开Eclipse时,出现: Failed to create the Java Virtual Machine 点击确定,ecl ...

  7. Decimal

    Description 任意一个分数都是有理数,对于任意一个有限小数,我们都可以表示成一个无限循环小数的形式(在其末尾添加0),对于任意一个无限循环小数都可以转化成一个分数.现在你的任务就是将任意一个 ...

  8. poj2752 Seek the Name, Seek the Fame

    Description The little cat is so famous, that many couples tramp over hill and dale to Byteland, and ...

  9. js设计模式系列之(一)请节约你的请求-代理模式

    What’s the proxy pattern? 代理模式其实就是将违反单一性原则的类给抽离出来,尽量满足开放和封闭的原则. 相当于一个类的行为只是一种,但是你可以给这个类添加额外的行为.比如: 一 ...

  10. topas top vmstat

    Linux监控脚本 http://www.jb51.net/article/58799.htm  http://blog.csdn.net/icescream6/article/details/456 ...