zoukankan      html  css  js  c++  java
  • AtCoder Regular Contest 080 C

    地址:http://arc080.contest.atcoder.jp/tasks/arc080_a

    题目:

    C - 4-adjacent


    Time limit : 2sec / Memory limit : 256MB

    Score : 400 points

    Problem Statement

    We have a sequence of length Na=(a1,a2,…,aN). Each ai is a positive integer.

    Snuke's objective is to permute the element in a so that the following condition is satisfied:

    • For each 1≤iN−1, the product of ai and ai+1 is a multiple of 4.

    Determine whether Snuke can achieve his objective.

    Constraints

    • 2≤N≤105
    • ai is an integer.
    • 1≤ai≤109

    Input

    Input is given from Standard Input in the following format:

    N
    a1 a2  aN
    

    Output

    If Snuke can achieve his objective, print Yes; otherwise, print No.


     

    思路:求膜2为1,膜4为0的数有多少个就好了。

     1 #include <bits/stdc++.h>
     2  
     3 using namespace std;
     4  
     5 #define MP make_pair
     6 #define PB push_back
     7 typedef long long LL;
     8 typedef pair<int,int> PII;
     9 const double eps=1e-8;
    10 const double pi=acos(-1.0);
    11 const int K=1e6+7;
    12 const int mod=1e9+7;
    13  
    14 int n,a,b,c,ans;
    15  
    16 int main(void)
    17 {
    18     scanf("%d",&n);
    19     for(int i=1,x;i<=n;i++)
    20     {
    21         scanf("%d",&x);
    22         if(x%4==0) c++;
    23         else if(x%2==0) b++;
    24         else a++;
    25     }
    26     c-=a;
    27     if(c>=0||(c==-1&&b==0)) puts("Yes");
    28     else    puts("No");
    29     return 0;
    30 }
  • 相关阅读:
    当一个模块没有默认导出
    <<平仓>>
    模态对话框
    PlanB S2F 模型
    <<深入React技术栈>> CSS Modules
    状态提升
    ol.proj.transform 坐标系转换
    HTMLVideoElement.srcObject MediaStream MediaSource Blob File
    毛玻璃特效 backdrop-filter
    Filter
  • 原文地址:https://www.cnblogs.com/weeping/p/7296608.html
Copyright © 2011-2022 走看看