其他分享
首页 > 其他分享> > 1624C - Division by Two and Permutation(1100)

1624C - Division by Two and Permutation(1100)

作者:互联网

#include<bits/stdc++.h>
using namespace std;
int vis[10005],a[10005],t,n;
int main(){
    scanf("%d",&t);
    while(t--){
    bool flag = true;
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            scanf("%d",&a[i]);
        }
        memset(vis,0,sizeof(vis));    
        for(int i=1;i<=n;i++){
            while(a[i]!=0&&(a[i]>n||vis[a[i]]==1)){
                a[i]/=2;
            }    
            if(a[i]==0){
                flag=false;
                break;
            }
            vis[a[i]]=1;                
        }
        if(flag) printf("YES\n");
        else printf("NO\n");
    }    
}

 

标签:Division,10005,int,scanf,printf,Two,vis,flag,Permutation
来源: https://www.cnblogs.com/happycrazy/p/15805848.html