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

Por Costel and Azerah

Descriptions

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

Example

Input
2
3
3 10 1
2
4 2
Output
3
3
题目链接
恶心死了  

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;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值