B. Valerii Against Everyone (Thinking)

https://codeforces.com/contest/1438/problem/B


Idea: Since the range of bi is 1e9, it is impossible for you to start from the perspective of calculating the a[] array first.

So we look at the sample, there are 2^4; 2^4=2^3+2^2+2^1+2^0+1;

Seeing that 1 is actually 2^0; that is to say, if a number can be comprehensively represented by other numbers, then there must be at least two 0s; and when there are two 0s, l1=r1 and l2=r2 are respectively equal to that Two numbers are enough. Two other numbers that are the same are directly satisfied.

#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e5;
typedef long long LL;
map<LL,LL>map1;
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  LL t;cin>>t;
  while(t--){
    LL n;cin>>n;
    map1.clear();
    for(LL i=1;i<=n;i++) {
        LL x;cin>>x;
        map1[x]++;
    }
    bool flag=1;
    for(auto i:map1){
        if(i.second>=2){
            flag=0;
            cout<<"YES"<<endl;
            break;
        }
    }
    if(flag==1){
        cout<<"NO"<<endl;
    }
  }
return 0;
}

 

Guess you like

Origin blog.csdn.net/zstuyyyyccccbbbb/article/details/112990823