您的位置:首页 > 其它

【Gym - 100923A】Por Costel and Azerah(思维水题)

2019-07-22 23:08 711 查看

Por Costel and Azerah

Descriptions

给你n个数 问你,有多少个子序列 的和是偶数 

Example

Input
2
3
3 10 1
2
4 2
Output
3
3
题目链接 https://vjudge.net/problem/Gym-100923A   恶心死了  

freopen("azerah.in","r",stdin);
freopen("azerah.out","w",stdout);

必须加上 不然一直错  卡了我1小时

直接看代码吧 挺水的

 

AC代码

#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define Mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define Maxn 1000010
using namespace std;
ll T,n;
int main()
{
freopen("azerah.in","r",stdin);
freopen("azerah.out","w",stdout);
cin>>T;
while(T--)
{
cin>>n;
ll x;
ll n1=0;//奇数个数
ll n2=0;//偶数个数
for(ll i=1; i<=n; i++)
{
cin>>x;
if(x%2)
n1++;
else
n2++;
}
ll s1=1;//奇数中的偶数子序列个数=2^(s1-1)-1
ll s2=1;//偶数中的偶数子序列个数=2^s2-1
//怕溢出,就一步一步循环吧
for(ll i=1; i<=n2; i++)
{
s1*=2;
s1%=Mod;
}
for(ll i=1; i<n1; i++)
{
s2*=2;
s2%=Mod;
}
s1--;
s2--;
cout<<(s1+s2+s1*s2)%Mod<<endl;
}
return 0;
}

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: