Submission #1410165
Source Code Expand
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
typedef long long ll;
map<ll, int> enumpr(ll n) {
map<ll, int> V;
for (ll i = 2; i*i <= n; i++) while (n%i == 0) V[i]++, n /= i;
if (n>1) V[n]++;
return V;
}
ll aCb(ll a, ll b)
{
if (a < b) return 0;
map<ll, int> up;
rep(i, 0, b) {
auto e = enumpr(a - i);
fore(p, e) up[p.first] += p.second;
}
rep(i, 0, b) {
auto e = enumpr(b - i);
fore(p, e) up[p.first] -= p.second;
}
ll res = 1;
fore(p, up) {
rep(i, 0, p.second) res *= p.first;
}
return res;
}
/*---------------------------------------------------------------------------------------------------
∧_∧
∧_∧ (´<_` ) Welcome to My Coding Space!
( ´_ゝ`) / ⌒i
/ \ | |
/ / ̄ ̄ ̄ ̄/ |
__(__ニつ/ _/ .| .|____
\/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/
int N, P, A[101];
//---------------------------------------------------------------------------------------------------
void _main() {
cin >> N >> P;
rep(i, 0, N) cin >> A[i];
int odd = 0, even = 0;
rep(i, 0, N) {
if (A[i] % 2 == 1) odd++;
else even++;
}
ll ans = -1;
if (P == 0) {
ans = 0;
int c = 0;
while (c <= odd) ans += aCb(odd, c), c += 2;
rep(i, 0, even) ans *= 2;
} else {
ans = 0;
int c = 1;
while (c <= odd) {
ans += aCb(odd, c);
c += 2;
}
rep(i, 0, even) ans *= 2;
}
printf("%lld\n", ans);
}
Submission Info
Submission Time |
|
Task |
A - Biscuits |
User |
hamayanhamayan |
Language |
C++14 (GCC 5.4.1) |
Score |
200 |
Code Size |
2172 Byte |
Status |
AC |
Exec Time |
1 ms |
Memory |
256 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
200 / 200 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample1.txt, sample2.txt, sample3.txt, sample4.txt |
All |
sample1.txt, sample2.txt, sample3.txt, sample4.txt, in1.txt, in2.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, sample1.txt, sample2.txt, sample3.txt, sample4.txt |
Case Name |
Status |
Exec Time |
Memory |
in1.txt |
AC |
1 ms |
256 KB |
in2.txt |
AC |
1 ms |
256 KB |
in3.txt |
AC |
1 ms |
256 KB |
in4.txt |
AC |
1 ms |
256 KB |
in5.txt |
AC |
1 ms |
256 KB |
in6.txt |
AC |
1 ms |
256 KB |
in7.txt |
AC |
1 ms |
256 KB |
in8.txt |
AC |
1 ms |
256 KB |
sample1.txt |
AC |
1 ms |
256 KB |
sample2.txt |
AC |
1 ms |
256 KB |
sample3.txt |
AC |
1 ms |
256 KB |
sample4.txt |
AC |
1 ms |
256 KB |