Educational Codeforces Round 96 (Rated for Div. 2) (A - C题个人题解)
因为火锅导致错过的上分机会😂,赛后发现人均AC5题
1430A. Number of Apartments
暴力搜索
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
void solve() {
cin >> n;
//bool flag = false;
for (int i = 0; i * 3 <= n; i++)
for (int j = 0; j * 5 <= n; j++)
if ((n - i * 3 - j * 5) % 7 == 0) {
cout << i << " " << j << " " << (n - i * 3 - j * 5) / 7 << endl;
return;
}
cout << -1 << endl;
}
int main() {
//freopen("in.txt", "r", stdin);
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int _; cin >> _; while (_--)solve();
}
1430B. Barrels
对水桶排序,累加后面k个水量即可
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 100;
ll n, k, a[N];
void solve() {
cin >> n >> k;
for (ll i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);ll l = a[n - 1];
for (ll i = n - 2; i >= n - k - 1; i--) { l += a[i]; }cout << l << endl;
}
int main() {
int _; cin >> _; while (_--)solve();
}
1430C. Numbers on Whiteboard
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 100;
ll n, k, a[N], _, m;
void solve() {
cin >> n; m = n; k = n - 1;
cout << 2 << '\n';
for (int i = 2; i <= n; ++i) {
cout << k << ' ' << m << '\n';
m = (k + m + 1) / 2; --k;
}
}
int main() {
int _; cin >> _; while (_--)solve();
}