A.
#include<bits/stdc++.h>
using namespace std;
int main () {
int t;
cin >> t;
while(t--) {
int n, k;
cin >> n >> k;
string s;
cin >> s;
if(k == 0) {
cout << "YES" << endl;
continue;
}
int gap = (n & 1) ? n / 2 : n / 2 - 1;
if(gap < k) {
cout << "NO" << endl;
continue;
}
bool isok = 0;
for(int i = 0; i < k; ++i) {
if(s[i] != s[n - i - 1]) {
isok = 1;
break;
}
}
if(isok) {
cout << "NO" << endl;
} else {
cout << "YES" << endl;
}
}
}
B
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
int t;
cin >> t;
while(t--) {
ll n, k;
cin >> n >> k;
std::vector<ll> v(n);
ll a[100010];
std::map<ll, int> mp;
for(int i = 0; i <= 100001; ++i) {
a[i] = 0;
}
ll maxx = -1;
for(int i = 0; i < n; ++i) {
cin >> v[i];
if(v[i] <= 100001) a[v[i]]++;
mp[v[i]] = 1;
maxx = max(maxx, v[i]);
}
ll mexx = -1;
for(int i = 0; i <= 100001; ++i) {
if(a[i] == 0) {
mexx = i;
break;
}
}
ll keyy = ll((double(mexx) + double(maxx)) / 2.0 + 0.5);
if(k == 0 || mp[keyy] == 1) {
cout << n << endl;
} else if(keyy > maxx) {
cout << n + k << endl;
} else {
cout << n + 1 << endl;
}
}
}
C
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
ios::sync_with_stdio(false);
int t;
cin >> t;
cout.precision(15);
while(t--) {
int n;
cin >> n;
std::vector<ll> vx;
std::vector<ll> vy;
for(int i = 0; i < 2 * n; ++i) {
ll x, y;
cin >> x >> y;
if(x == 0) vy.push_back(abs(y));
else vx.push_back(abs(x));
}
sort(vx.begin(), vx.end());
sort(vy.begin(), vy.end());
double ans = 0.0;
for(int i = 0; i < n; ++i) {
ans += sqrt(vx[i] * vx[i] + vy[i] * vy[i]);
}
cout << ans << endl;
}
}
注意不要用double 容易t
Codeforces Round #706 (Div. 2)(补题)
原文:https://www.cnblogs.com/lightac/p/14514959.html