Codeforces Round #636 (Div. 3)题解

 

 白给题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;
			}
		}
	}
}

 

 

 白给题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;
	}
}

 

 

 白给题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;
	}
}

 后面题待更新。。。

作者:LightAc
出处:https://www.cnblogs.com/lightac/
联系:
Email: dzz@stu.ouc.edu.cn
QQ: 1171613053
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/lightac/p/12750108.html