给定一些数,判断是否能通过重新排序使得相邻的两个数相乘为4的倍数
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <algorithm>
#define x first
#define y second
#define pb emplace_back
#define fu(i,a,b) for(int i=a;i<=b; ++ i)
#define fd(i,a,b) for(int i=a;i>=b; -- i)
#define endl '\n'
#define ms(x,y) memset(x,y,sizeof x)
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<vector<LL>> VVL;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<bool> VB;
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef pair<PII,int> PIII;
typedef pair<double,double> PDD;
typedef pair<double,int> PDI;
typedef pair<char,int> PCI;
typedef pair<string,int> PSI;
typedef pair<int,string> PIS;
typedef pair<int,char> PIC;
typedef pair<LL,LL> PLL;
typedef __int128 i128;
typedef unsigned long long ULL;
const int N =2e5 + 10 ,M = N *5,INF = 0x3f3f3f3f,P = 131;
const double eps = 1e-8,DNF = 1e18;
const int mod = 998244353 ,base= 20010;
const LL LNF=(LL) INF * INF;
int c1,c4;
void solve()
{
int n;cin >> n;
fu(i,0,n-1)
{
int t;cin >> t;
if(t & 1 )c1++ ; // % 4 == 1 or 3
else if(!(t & 3))c4 ++ ;
// 1,2,3 & 3 = 1 ,4 & 3 = 0
}
int c2 = n - c4 - c1;
if(c2) c2 = 1; //存在 模4 为2的数,需要在一个4的旁边
if(!c1 || c1 + c2 <= c4 + 1 )cout <<"Yes";
// 奇数和 模4 为2的数都需要一个4在身边,4如果在内侧 ,就可以搭配c4 + 1 个非模4为0的数
// 2434444 14243444
else cout <<"No";
}
signed main()
{
// freopen("1.txt","r",stdin);
// #define int long long
// init(N-1);
ios
// cout << fixed<<setprecision(2);
int t=1;
// cin>>t;
int now = 1;
while(t -- )
{
// cout<<"Case ";
// cout<<"Case #";
// cout<<"Scenario #";
// cout<< now ++ <<": ";
// cout<< now ++ <<": \n";
solve();
}
return 0;
}