Educational Codeforces Round 156 (Rated for Div. 2)A~C

A

Problem - A - Codeforces

#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

Problem - B - Codeforces

#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

Problem - C - Codeforces

删除字符串的最优策略是当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;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值