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
 
Source


看数字找规律吧。。。

随便试试竟然就试过了。


#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <climits>
using namespace std; #define ls 2*i
#define rs 2*i+1
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define W(a) while(a)
#define gcd(a,b) __gcd(a,b)
#define LL long long
#define N 1005
#define INF 0x3f3f3f3f
#define EXP 1e-8
#define rank rank1
const int mod = 1000000007;
LL ppow(LL a,LL b)
{
LL c=1;
while(b)
{
if(b&1) c=c*a%mod;
b>>=1;
a=a*a%mod;
}
return c;
}
int main()
{
int t;
LL n;
scanf("%d",&t);
while(t--)
{
scanf("%I64d",&n);
printf("%I64d\n",ppow(2,n-1)-1);
} return 0;
}

HDU5363:Key Set的更多相关文章

  1. Key/Value之王Memcached初探:二、Memcached在.Net中的基本操作

    一.Memcached ClientLib For .Net 首先,不得不说,许多语言都实现了连接Memcached的客户端,其中以Perl.PHP为主. 仅仅memcached网站上列出的语言就有: ...

  2. Dapper.Contrib:GetAsync<T> only supports an entity with a [Key] or an [ExplicitKey] property

    异常处理:http://www.cnblogs.com/dunitian/p/4523006.html#dapper 原来Model是这样滴 修改后是这样滴 注意点:Model里面的Table和Key ...

  3. Redis百亿级Key存储方案(转)

    1 需求背景 该应用场景为DMP缓存存储需求,DMP需要管理非常多的第三方id数据,其中包括各媒体cookie与自身cookie(以下统称supperid)的mapping关系,还包括了supperi ...

  4. 【详细教程】论android studio中如何申请百度地图新版Key中SHA1值

    一.写在前面 现在越来越多的API接口要求都要求提供我们的项目SHA1值,开发版目前还要求不高,但是发布版是必定要求的.而目前定位在各大APP中也较为常见,当下主流的百度地图和高德地图都在申请的时候会 ...

  5. CentOS:ECDSA host key "ip地址" for has changed and you have requested strict checking(转)

    原文地址:http://blog.csdn.net/ausboyue/article/details/52775281 Linux SSH命令错误:ECDSA host key "ip地址& ...

  6. webstorm license key

    JetBrains WebStorm注册码 UserName: William License Key : ===== LICENSE BEGIN ===== 45550-12042010 00001 ...

  7. VS2015企业版本(安装包+key)+ .NET Reflector 9.0

    Reflector9.0系下载:https://yunpan.cn/cMQj9zWbffSqy  访问密码 55eb VS2015中文企业版: http://pan.baidu.com/s/1eRIo ...

  8. Redis系列之key操作命令与Redis中的事务详解(六)

    序言 本篇主要目的有二: 1.展示所有数据类型中key的所有操作命令,以供大家学习,查阅,更深入的挖掘redis潜力. 2.掌握redis中的事务,让你的数据完整性一致性拥有更优的保障. redis命 ...

  9. SQL Server-聚焦移除Bookmark Lookup、RID Lookup、Key Lookup提高SQL查询性能(六)

    前言 前面几节都是讲的基础内容,本节我们讲讲索引性能优化,当对大数据进行处理时首先想到的就是索引,一旦遇到这样的问题则手忙脚乱,各种查资料,为何平常不扎实基本功呢,我们由浅入深,简短的内容,深入的理解 ...

随机推荐

  1. iOS-Http : GET : POST

    一.概述 * HTTP/1.1协议共定义了8中请求方法:OPTIONS, HEAD, GET, POST, PUT, DELETE, TRACE, CONNECT. * GET方法和POST是我们使用 ...

  2. java追加文本到文件末尾

    public class Test { public static void main(String[] args) { method1("F:\\test.txt" , &quo ...

  3. BeanFactory到WebApplicationContext的结构 以及bean和spring容器的关系

    BeanFactory: Ioc 容器 ApplicationContext: Spring容器 WebApplicationContext需要ServletContext实例,也就是说它必须在拥有W ...

  4. Idea连接服务器docker并部署代码到docker实现一键启动

    好记性不如烂笔头,写笔记是为了回头看的. 谁要是不小心搜了看了,如有不足之处敬请谅解. 一.准备工作 虚拟机centos7.X,docker1.3.X,Win10 Idea2018.1 默认Idea已 ...

  5. openxml的视频教程

    http://msdnwebcast.net/webcast/0/1980/#1032360142 最近发现的一个openxml的视频教程

  6. Quotes in shell(bash, csh)

    There are three kinds of quote: single quote('), double quote("), backslash(\), how shell expla ...

  7. vue.js源码学习分享(三)

    /** * Mix properties into target object.//把多个属性插入目标的对象 */ function extend (to, _from) { for (var key ...

  8. 反汇编->C++引用与指针

    先看一段最简单代码 #include<iostream> #include<stdlib.h> using namespace std; int main() { int te ...

  9. hdu 4503(数学,概率)

    湫湫系列故事——植树节 Time Limit: 1000/500 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total ...

  10. Cmder 快捷键

    1, Cmder常用快捷键 利用Tab,自动路径补全: 利用Ctrl+T建立新页签:利用Ctrl+W关闭页签; 利用Ctrl+Tab切换页签; Alt+F4:关闭所有页签 Alt+Shift+1:开启 ...