非空子集个数
来源:互联网 发布:java工程师年龄要求 编辑:程序博客网 时间:2024/05/16 00:47
A - A
Time Limit:1000MS Memory Limit:131072KB 64bit IO Format:%I64d & %I64uDescription
soda has a set with integers . 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 are key set.
Input
There are multiple test cases. The first line of input contains an integer , indicating the number of test cases. For each test case:
The first line contains an integer , the number of integers in the set.
The first line contains an integer
Output
For each test case, output the number of key sets modulo 1000000007.
Sample Input
41234
Sample Output
0137
首先要理解题意,注意细节,这道题的意思是一个集合S中有n个整数,求元素个数为偶数的非空子集有多少个,知道公式2^(n-1)(mod)-1;就很简单了
记得是要对1000000007取模!!
1234567891011121314151617181920212223242526#include<stdio.h>__int64 f(__int64 a,__int64 b,__int64 c){__int64 t=1;a=a%c;while(b>0){if(b%2==1)t=t*a%c;b=b/2;a=a*a%c;}return t;}int main(){int t;__int64 n;scanf("%d",&t);while(t--){scanf("%I64d",&n);printf("%I64d\n",f(2,n-1,1000000007)-1);}return 0;}
0 0
- 非空子集个数
- 非空子集个数计算
- 字符串的非空子集
- 列出一个集合的所有非空子集
- 输出一个字符串数组所有非空子集
- 求集合元素的所有非空子集
- 利用格雷码找出集合的所有非空子集
- 字符串的所有组合(非空子集)
- 计算非空单元格的个数
- 在Excel中统计出指定区域的空单元格个数和非空单元格个数
- 真子集的个数
- 请编写一个方法,返回某集合的所有非空子集。
- 二叉树-求{0,1....n-1}的非空子集
- 证明满节点的个数加1等于非空二叉树的树叶的个数。
- 无序子集合个数问题
- 一个集合的子集个数的计算方法
- 任意N个数的子集生成算法
- 子集算法(PHP): 求一个非空集合的子集
- Netty解决半包(TCP粘包/拆包导致)读写问题
- fontspider--字蛛的使用
- 大话设计模式13----建造者模式
- 【bzoj3611】 大工程
- 杭电5562之Clarke and food
- 非空子集个数
- wireshark捕获/过滤指定ip地址数据包
- constantize()函数
- Graham求凸包
- POJ 3450 Corporate Identity(kmp求多个字符串的最长公共子串)
- [HDU 2222] Keywords Search [AC自动机]
- 剑指offer 37题 【时间空间效率的平衡】两个链表的第一个公共结点
- 二、词法结构
- ISO12233分辨率测试卡的使用方法