其他分享
首页 > 其他分享> > Codeforces Round #726 (Div. 2)

Codeforces Round #726 (Div. 2)

作者:互联网

又是天崩开局…

A

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll t, n, m;
inline void solve() {
	cin >> n;
	ll sum = 0;
	for(int i = 1; i <= n; i++) {
		ll x; cin >> x;
		sum += x;
	}
	if(sum < n) cout << 1 << endl;
	else cout << sum - n << endl;
	return ;
}
int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> t;
	while(t--) {
		solve();
	}
	return 0;
} 

B

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
const ll N = 1e6 + 10;
ll t, n, m, x, y;
inline void solve() {
	cin >> n >> m >> x >> y;
	cout << 1 << " " << 1 << " " << n << " " << m << endl;
	return ;
}
int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> t;
	while(t--) {
		solve();
	}
	return 0;
} 

C

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
const ll N = 1e6 + 10;
ll t, n, m, x[N];
inline void solve() {
	cin >> n;
	int flag = 0; 
	for(int i = 1; i <= n; i++) cin >> x[i];
	sort(x + 1, x + n + 1);
	int st, ed, now = 0x3f3f3f3f3f3f3f;
	for(int i = 2; i <= n; i++) {
		if(x[i] - x[i - 1] < now) {
			st = i - 1;
			ed = i;
			now = x[i] - x[i - 1];
		}
	}
	vector<int> ans;
	int ok1 = 0, ok2 = 0;
	cout << x[st] << " ";
	for(int i = 1; i <= n; i++) {
		if(ok1 == 0 && x[i] == x[st]) {
			ok1 = 1; continue;	
		}
		if(ok2 == 0 && x[i] == x[ed]) {
			ok2 = 1; continue;
		}
		ans.push_back(x[i]);
	}
	if(n > 2) {
		int pos = 0;
		for(int i = 0; i < ans.size(); i++) 
			if(ans[i] > x[st]) {
				pos = i; break;
		}
		for(int i = pos; i < ans.size(); i++) cout << ans[i] << " ";
		for(int i = 0; i < pos; i++) cout << ans[i] << " ";
	}
	cout << x[ed] << endl;
	return ;
}
int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> t;
	while(t--) {
		solve();
	}
	return 0;
}

D

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll t, n, m;
inline void solve() {
	cin >> n;
	if(n % 2 == 1) {
		cout << "Bob" << endl; 
		return ;
	} 
	int cnt = 1;
	for(; pow(2, cnt) <= n; cnt+=2) {
		if(pow(2, cnt) == n) {
			cout << "Bob" << endl; 
			return ;
		}
	}
	cout << "Alice" << endl;
	return ;
}
int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> t;
	while(t--) {
		solve();
	}
	return 0;
}

E1

#include <bits/stdc++.h>
using namespace std;
int main() {
	string s; int k, n; cin >> n >> k >> s;
	int now = 0, ans = 0; 
	for(int i = 1; i < s.size(); i++) {
		if(s[i] > s[now]) break;
		else if(s[i] == s[now]) now++;
		else {
			ans = i;
			now = 0;
		}
	}
	now = 0;
	while(k--) {
		cout << s[now];
		if(now == ans) now = 0;
		else now++;
	}
	return 0;
}

E2

标签:int,ll,Codeforces,long,cin,726,Div,now,sum
来源: https://blog.csdn.net/a12311weq/article/details/118058306