题目链接: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. 『安全工具』目录扫描 DirBuster AND 御剑

    要想熟悉目标网站的体系架构,知道网站有哪些目录是必不可少的 向AWVS,Burp类大型扫描工具也可以进行目录扫描,不过个人感觉远没有专业扫描工具来的简单,实在 0x 01 DirBuster 简介:D ...

  2. cf B. Fence

    http://codeforces.com/contest/363/problem/B #include <cstdio> #include <cstring> #includ ...

  3. Borland license information was found,but it is not valid for delphi.

    The start Delphi7 come amiss: Borland license information was found,but it is not valid for delphi. ...

  4. bzoj1624 [Usaco2008 Open] Clear And Present Danger 寻宝之路

    Description     农夫约翰正驾驶一条小艇在牛勒比海上航行.     海上有N(1≤N≤100)个岛屿,用1到N编号.约翰从1号小岛出发,最后到达N号小岛.一 张藏宝图上说,如果他的路程上 ...

  5. perl 学习笔记

    一:基础 1:安装perl      centos: yum -y install perl       官网:https://www.perl.org/      升级到5.22:先下载,执行./i ...

  6. phpcms:二、头部尾部包含

    1.index.html是默认的首页{template "content","header"}引入头部的模块{template "content&qu ...

  7. Activity小结

    Log日志类的五种级别 1.由高到低分别是:v.i.d.w.e 2.生命周期有七种状态: onCreate:创建 onStart:启动 onResume:显示(可以与用户交互) onPause:暂停 ...

  8. JSF标签大全详解

    1. JSF入门 藉由以下的几个主题,可以大致了解JSF的轮廓与特性,我们来看看网页设计人员与应用程序设计人员各负责什么. 1.1简介JSF Web应用程序的开发与传统的单机程序开发在本质上存在着太多 ...

  9. Fragment的简单使用

    最近一直有点忙,刚刚看到一个朋友的留言提到Fragment中加载ListView的问题,这里写了一个非常简单的测试,至于对Fragment的增.删.改实现动态布局构建灵活的UI,以后有时间在讨论: M ...

  10. Servlet登陆功能的实现

    (1)创建动态的Login页面 //登陆界面 package com.lc; import javax.servlet.http.*; import java.io.*; public class L ...