noi前橙名计划失败。全程搞C而gg……

A - Biscuits

题意:背包,求价值为奇/偶的方案数。

#include<cstdio>
#include<queue>
#include<algorithm>
#define ld long double
#define MN 21000000
using namespace std;
 
int read_p,read_ca;
inline int read(){
    read_p=0;read_ca=getchar();
    while(read_ca<'0'||read_ca>'9') read_ca=getchar();
    while(read_ca>='0'&&read_ca<='9') read_p=read_p*10+read_ca-48,read_ca=getchar();
    return read_p;
}
int n,p,a;
long long mmh[2];
int main(){
    mmh[0]=1;
    n=read();p=read();
    while(n--){
        a=read()&1;
        if (a&1){
            mmh[0]=mmh[1]=mmh[1]+mmh[0];
        }else mmh[0]<<=1,mmh[1]<<=1;
    }
    printf("%lld\n",mmh[p]);
}
View Code

相关文章:

  • 2021-07-10
  • 2021-12-19
  • 2021-05-30
  • 2021-11-21
  • 2022-01-18
  • 2022-01-06
  • 2022-02-05
  • 2022-02-20
猜你喜欢
  • 2022-12-23
  • 2021-12-18
  • 2021-11-19
  • 2022-01-16
相关资源
相似解决方案