Codeforces Round # 636 (Div. 3)

 

 

 

 White to Question 1

#include <bits/stdc++.h>
using namespace std;
int main () {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t;
	cin >> t;
	while(t--) {
		int n;
		cin >> n;
		for(int k = 2;  (1 << k) - 1 <= n; ++k) {
			if(n % ((1 << k) - 1) == 0) {
				cout << n / ((1 << k) - 1) << endl;
				break;
			}
		}
	}
}

 

 

 

 

 White Question 2

#include <bits/stdc++.h>
using namespace std;
int main () {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t;
	cin >> t;
	while(t--) {
		int n;
		cin >> n;
		if(n % 4 != 0) {
			cout << "NO" << endl;
			continue;
		}
		cout << "YES" << endl;
		for(int i = 1; i <= n / 2; ++i) {
			cout << 2 * i << " ";
		}
		for(int i = 1; i < n / 2; ++i) {
			cout << 2 * i - 1 << " ";
		}
		cout << n + n / 2 - 1 << endl;
	}
}

 

 

 

 

 White to Question 3

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t;
	cin >> t;
	while(t--) {
		int n;
		cin >> n;
		std::vector<ll> v;
		for(int i = 0; i < n; ++i) {
			ll temp;
			cin >> temp;
			v.push_back(temp);
		}
		int op = 0;
		int top = 0;
		op = v[0] > 0 ? 1 : -1;
		ll maxx = v[0];
		ll ans = 0;
		for(int i = 1; i < n; ++i) {
			top = v[i] > 0 ? 1 : -1;
			if(top != op) {
				ans += maxx;
				op = top;
				maxx = v[i];
			}
			else {
				maxx = max(maxx, v[i]);
			}
		}
		ans += maxx;
		cout << ans << endl;
	}
}

 Later questions are to be updated. . .

Guess you like

Origin www.cnblogs.com/lightac/p/12750108.html