A
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 30;
int gcd(int a, int b) {
return b ? gcd(b, a % b) : a;
}
inline void solve(){
int n; cin >> n;
if (n <= 6||n==9) {
cout << "NO" << '\n';
return;
}
if (n % 3 != 0) {
cout << "YES" << '\n';
cout << 1 << ' ' << 2 << ' ' << n - 3 << '\n';
return;
}
cout << "Yes" << '\n';
cout << 1 << ' ' << 4 << ' ' << n - 5 << '\n';
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
std::cout.tie(0);
int t = 1;
cin >> t;
while (t--)
solve();
return 0;
}
B
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 30;
int gcd(int a, int b) {
return b ? gcd(b, a % b) : a;
}
inline void solve(){
double px, py, ax, ay, bx, by;
cin >> px >> py >> ax >> ay >> bx >> by;
double a = sqrt((ax - px) * (ax - px) + (ay - py) * (ay - py));
double b = sqrt((bx - px) * (bx - px) + (by - py) * (by - py));
double c = sqrt((ax) * (ax)+(ay) * (ay));
double d = sqrt((bx) * (bx)+(by) * (by));
double e = sqrt((bx - ax) * (bx - ax) + (by - ay) * (by - ay));
double ans = max(min(a, b), min(c, d));
bool fg = 1;
if ((a >= b && c >= d) || (a <= b && c <= d))
fg = 0;
if (fg && 2 * ans < e)
ans = e / 2;
cout << fixed << setprecision(10) << ans << '\n';
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
std::cout.tie(0);
int t = 1;
cin >> t;
while (t--)
solve();
return 0;
}
C
删除字符串的最优策略是当ti>ti+1,删ti
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 30;
int gcd(int a, int b) {
return b ? gcd(b, a % b) : a;
}
string ans1;
inline void solve(){
string s; cin >> s;
ll p; cin >> p;
ll n = s.size();
ll f = 0;
ll t = n;
if (p <= n) {
ans1 = ans1 + s[p - 1];
return;
}
while (p>t) {
f++;
p -= t;
t--;
}
string s2;
for (auto& si : s) {
while (f && !s2.empty() && s2.back() > si) {
s2.pop_back();
f--;
}
s2.push_back(si);
}
ans1 = ans1 + s2[p-1];
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
std::cout.tie(0);
int t = 1;
cin >> t;
while (t--)
solve();
cout << ans1 << '\n';
return 0;
}