• F


     1 // worfzyq
     2 #include <cstdio>
     3 #include <cstring>
     4 #include <vector>
     5 #include <algorithm>
     6 #include <map>
     7 #include <string>
     8 #include <set>
     9 using namespace std;
    10 typedef long long LL;
    11 const int MAX = 1e5+10;
    12 const int MOD = 1e9+7;
    13 int dp[110][1<<16],has[110];
    14 int prime[15]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
    15 int a[MAX];
    16 void init() {
    17     memset(has,0,sizeof(has));
    18     for(int i=1;i<=100;i++) {
    19         for(int j=0;j<15;j++) {
    20             if(i%prime[j]==0) {
    21                 has[i]|=(1<<j);
    22             }
    23         }
    24     }
    25 }
    26 int main() {
    27     //freopen("in.txt","w",stdout);
    28     init();
    29     int n,x;
    30     while(scanf("%d %d",&n,&x)==2) {
    31         for(int i=0;i<n;i++) {
    32             scanf("%d",&a[i]);
    33         }
    34         memset(dp,0,sizeof(dp));
    35         for(int i=0;i<n;i++) {
    36             for(int j=0;j<(1<<15);j++) {
    37                 dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
    38                 if((j&has[a[i]])==0) {
    39                     dp[i+1][j|has[a[i]]]=max(dp[i+1][j|has[a[i]]],dp[i][j]+1);
    40                 }
    41             }
    42         }
    43         int ans=0;
    44         for(int i=0;i<(1<<15);i++) {
    45             ans=max(ans,dp[n][i]);
    46         }
    47         if(n&1) {
    48             if(ans>=n/2) {
    49                 if(x>=1) printf("YES ");
    50                 else printf("NO ");
    51             }
    52             else {
    53                 if(x>=n-ans*2) {
    54                     printf("YES ");
    55                 }
    56                 else {
    57                     printf("NO ");
    58                 }
    59             }
    60         }
    61         else {
    62             if(ans>=n/2) {
    63                 printf("YES ");
    64             }
    65             else {
    66                 if(x>=n-ans*2) {
    67                     printf("YES ");
    68                 }
    69                 else {
    70                     printf("NO ");
    71                 }
    72             }
    73         }
    74     }
    75     return 0;
    76 }
  • 相关阅读:
    MUI 实现下拉刷新上拉加载的简单例子
    MySQL 游标的使用
    Java 策略模式
    [].slice.call(arguments,1) 个人理解
    Hbuilder + MUI 的简单案例
    传输SO10 (SO10 Transport)
    SAP 供应商/客户的冻结及其删除操作
    SAP FI CO模块常用事务代码
    SAP-批量修改主数据(客户、供应商、物料)
    远程主动读取数据 RFC_READ_TABLE
  • 原文地址:https://www.cnblogs.com/acvc/p/4303967.html
Copyright © 2020-2023  润新知