B. Valerii Against Everyone(思維)
阿新 • • 發佈:2021-01-23
技術標籤:思維
https://codeforces.com/contest/1438/problem/B
思路:由於bi的範圍1e9,所以不可能是讓你從先算出a[]陣列的角度出發。
於是我們看樣例,有2^4;2^4=2^3+2^2+2^1+2^0+1;
看到1其實是2^0;也就是說如果某個數能被其他數綜合表示出來,那麼至少要有兩個0;而有兩個0的時候,l1=r1和l2=r2分別等於那兩個數就滿足了。有其他相同的兩個數也是直接就滿足了。
#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; }