Submission #3448417


Source Code Expand

#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)

ll comb(ll n, ll k) {
//  if(k==n) return 1;
  ll ret=1;
  for(ll i=n; i>=n-k+1; i--) {
    ret*=i;
  }
  for(ll i=1; i<=k; i++) {
    ret/=i;
  }
  return ret;
}

ll aCb(ll a, ll b) {
  if(b==0 || a==b) return 1;
  return aCb(a-1,b-1)+aCb(a-1,b);
}

ll po(ll b, ll e) {
  if(e==0) return 1;
  if(e%2==0) {
    ll t = po(b,e/2);
    return t*t;
  }
  return b*po(b,e-1);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  ll n,p;
  //cout << comb(10,10) << endl;
  // rep(i,5) {
  //   rep(j,i+1) {
  //     cout << "comb(" << i << "," << j <<")=" <<comb(i,j) << endl;
  //   }
  // } 
  cin>>n>>p;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  ll o=0,e=0;
  rep(i,n) {
    if(a[i]%2==0) {
      e++;
    } else o++;
  }
  ll ans=0;
  for(ll k=p; k<=o; k+=2) {
    // ans+=comb(o,k);
    ans+=aCb(o,k);
  }
  cout << ans*po(2,e) << endl;
  return 0;
}

Submission Info

Submission Time
Task A - Biscuits
User ponpon05
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1178 Byte
Status AC
Exec Time 102 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 4
AC × 16
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 102 ms 256 KB
in2.txt AC 52 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 102 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 26 ms 256 KB