Codeforces Round 907 (Div. 2)

A.解释一下题意给定m,pow(2,m)a[i+1],就输出no,反之yes.

// Problem: A. Sorting with Twos
// Contest: Codeforces - Codeforces Round 907 (Div. 2)
// URL: https://codeforces.com/contest/1891/problem/A
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
int a[N];
void solve() {
	int n;
	cin>>n;
	bool flag=false;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;ia[i+1]){//判断i是不是二次幂。
			flag=true;
		}
	}
	if(flag){
		cout<<"NO"<<'\n';
	}else{
		cout<<"YES"<<'\n';
	}

}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int q;
	cin >> q;
	while (q--) {
		solve();
	}

	return 0;
}

你可能感兴趣的:(算法)