【Gym - 100923A】Por Costel and Azerah(思维水题)
2019-07-22 23:08
711 查看
Por Costel and Azerah
Descriptions
给你n个数 问你,有多少个子序列 的和是偶数
Example
Input2
3
3 10 1
2
4 2
Output题目链接 https://vjudge.net/problem/Gym-100923A 恶心死了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; }
相关文章推荐
- A - Por Costel and Azerah Gym - 100923A
- 【动态规划】Gym - 100923A - Por Costel and Azerah
- A - Por Costel and Azerah Gym - 100923A
- Por Costel and Azerah Gym - 100923A
- I - Por Costel and the Pairs Gym - 100923I _思维啊——可惜我现在还没
- 【并查集】Gym - 100923H - Por Costel and the Match
- 【带权并查集】Gym - 100923H - Por Costel and the Match
- 【数形结合】Gym - 100923I - Por Costel and the Pairs
- 【分块打表】Gym - 100923K - Por Costel and the Firecracker
- 【找规律】Gym - 100923L - Por Costel and the Semipalindromes
- L - Por Costel and the Semipalindromes Gym - 100923L
- 【Heap-dijkstra】Gym - 100923B - Por Costel and the Algorithm
- C. Bear and Different Names----思维水题
- 【HUD 1029】Ignatius and the Princess IV(思维-水题)
- UVA 1394 And Then There Was One / Gym 101415A And Then There Was One / UVAlive 3882 And Then There Was One / POJ 3517 And Then There Was One / Aizu 1275 And Then There Was One (动态规划,思维题)
- A. Alyona and copybooks--思维水题
- C. Alyona and mex--思维水题
- hpu暑假训练C - Patrick and Shopping 【思维】&&【水题】
- Codeforces #337 (Div.2)B.Vika and Squares【思维】水题
- Gym - 101572B-水题&思维漏洞&排序相关-B - Best Relay Team