题目链接: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. 一个图片上传的servlet,传到本地磁盘,要传到服务器请修改

    本来想写个controller,结果拦截器把图片拦住了,那就直接servlet public class UploadEamge extends HttpServlet{ /** * */ priva ...

  2. 关于开源中文搜索引擎架构coreseek中算法详解

     Coreseek 是一款中文全文检索/搜索软件,以GPLv2许可协议开源发布,基于Sphinx研发并独立发布,专攻中文搜索和信息处理领域,适用于行业/垂直搜索.论坛/站内搜索.数据库搜索.文档/文献 ...

  3. Android系统服务-简介

    http://blog.csdn.net/chenyafei617/article/details/6577907 Introduction 我们知道Android系统服务挺多的,做程序时经常会用到, ...

  4. KEIL中的变量相关

    例:sfr P0=0x80表示P0口地址为80H:(sfr是字节操作) sfr16 T2=0xCC表示T2口地址的低地址为TL2=0XCC,高地址为TH2=0XCD(sfr16是字操作) 头文件reg ...

  5. 开发支付宝支付用DELPHI实现 RSA签名

    近来根据业务需求 在ERP中集成了微信支付,支付宝支付,开发支付宝支付时最大的障碍就是RSA签名,找了很多资料,最终用 下了个libeay32.pas  根据网上资料最终解决了问题 function  ...

  6. 哲学家用餐问题的几个解法(c语言实现)

    参考资料: 1.维基百科:哲学家用餐问题 2.Windows的多线程编程

  7. Android 通过外键连接两个数据库

    Learn: 1.Android数据库的语法. 2.通过外键连接两个数据库. 3.加强了对数据库的熟悉度. 4.对文本框的visiblity属性的了解. Demo:http://pan.baidu.c ...

  8. WustOJ 1575 Gingers and Mints(快速幂 + dfs )

    1575: Gingers and Mints Time Limit: 1 Sec  Memory Limit: 128 MB   64bit IO Format: %lldSubmitted: 24 ...

  9. PHP设计模式笔记九:装饰器模式 -- Rango韩老师 http://www.imooc.com/learn/236

    装饰器模式(Decorator) 概述 1.装饰器模式可以动态地添加修改类的功能 2.一个类提供了一项功能,如果要在修改并添加额外的功能,传统的编程模式,需要写一个子类继承它,并重新实现类的方法 3. ...

  10. mysql判断某个字符串是否包含另一个

    like SELECT * FROM wx_webauth_userinfo where city LIKE "%台%";"; 结果: 函数find_in_set(str ...