csust-8.10早训CF之700-1700分

本文详细解析了CodeForces平台上的六道编程题,包括AntonandDanik、AntonandDigits、AntonandMakingPotions等,涵盖了字符串处理、数学计算、数据结构和算法等方面的知识。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目录

 

A - Anton and Danik

B - Anton and Digits

C - Anton and Making Potions

D - Ostap and Grasshopper

E - Urbanization

F - Tennis Championship


A - Anton and Danik

 CodeForces - 734A 

题目链接https://codeforces.com/problemset/problem/734/A

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false)
const int inf = 1e8 + 10;
const int mac = 1e5 + 10;
char s[mac];
int main()
{
	IOS;
	int n, d;
	cin >> n;
	cin >> s;
	int a1 = 0, d1 = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'D') d1++;
		else a1++;
	}
	if (a1 > d1) cout << "Anton" << endl;
	else if (a1 < d1) cout << "Danik" << endl;
	else cout << "Friendship" << endl;
	return 0;
}

B - Anton and Digits

 CodeForces - 734B 

题目链接https://codeforces.com/problemset/problem/734/B

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false)
#define ll long long
const int inf = 1e8 + 10;
const int mac = 1e5 + 10;
char s[mac];
int main()
{
	IOS;
	int k2, k3, k5, k6;
	ll sum = 0;
	cin >> k2 >> k3 >> k5 >> k6;
	while (k2 && k5 && k6) {
		k2--; k5--; k6--;
		sum += 256;
	}
	while (k2 && k3) {
		k2--; k3--;
		sum += 32;
	}
	cout << sum << endl;
	return 0;
}

C - Anton and Making Potions

 CodeForces - 734C 

题目链接https://codeforces.com/problemset/problem/734/C

#include <bits/stdc++.h>
using namespace std;
const int mac = 2e5 + 10;
#define IOS ios::sync_with_stdio(false)
#define ll long long
const ll inf = 1e18 + 10;
int a[mac], b[mac], c[mac], d[mac];
int main()
{
	IOS;
	int n, m, k;
	cin >> n >> m >> k;
	int x, s;
	cin >> x >> s;
	for (int i = 1; i <= m; i++) cin >> a[i];
	for (int i = 1; i <= m; i++) cin >> b[i];
	for (int i = 1; i <= k; i++) cin >> c[i];
	for (int i = 1; i <= k; i++) cin >> d[i];
	ll ans = (ll)(n - c[upper_bound(d + 1, d + 1 + k, s) - d - 1]) * x;
	for (int i = 1; i <= m; i++) {
		if (b[i] > s) continue;
		ans = min(ans, (ll)(n - c[upper_bound(d + 1, d + 1 + k, s - b[i]) - d - 1]) * a[i]);
	}
	cout << ans << endl;
	return 0;
}

D - Ostap and Grasshopper

 CodeForces - 735A 

题目链接https://codeforces.com/problemset/problem/735/A

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false)
const int inf = 1e8 + 10;
const int mac = 1e5 + 10;
char s[mac];
int main()
{
	IOS;
	int n, k;
	cin >> n >> k;
	cin >> s;
	int head = 0, st, fa, mark = 0;
	for (int i = 0; i < n; i++)
		if (s[i] == 'G') st = i;
		else if (s[i] == 'T') fa = i;
	head = st;
	while (head < n) {
		head += k;
		if (head >= n) break;
		if (head == fa) {
			mark = 1;
			cout << "YES" << endl;
			return 0;
		}
		if (s[head] == '#') break;
	}
	head = st;
	while (head >= 0) {
		head -= k;
		if (head < 0) break;
		if (head == fa) {
			mark = 1; cout << "YES" << endl;
			return 0;
		}
		if (s[head] == '#') break;
	}
	if (!mark) cout << "NO" << endl;
	return 0;
}

E - Urbanization

 CodeForces - 735B 

题目链接https://codeforces.com/problemset/problem/735/B

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false)
const int inf = 1e8 + 10;
const int mac = 1e5 + 10;
char s[mac];
int a[mac];
bool cmp(int x, int y)
{
	return x > y;
}
int main()
{
	//IOS;
	int n, n1, n2;
	cin >> n >> n1 >> n2;
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	sort(a + 1, a + 1 + n, cmp);
	double s1 = 0, s2 = 0;
	if (n1 > n2) swap(n1, n2);
	int q1 = n1, q2 = n2;
	int i = 1;
	while (n1) {
		n1--; s1 += a[i++];
	}
	while (n2) {
		n2--; s2 += a[i++];
	}
	s1 /= q1, s2 /= q2;
	double ans = s1 + s2;
	printf("%.8f\n", ans);
	return 0;
}

F - Tennis Championship

 CodeForces - 735C 

题目链接https://codeforces.com/problemset/problem/735/C

#include <bits/stdc++.h>
using namespace std;
const int mac = 2e5 + 10;
#define IOS ios::sync_with_stdio(false)
#define ll long long
const ll inf = 1e18 + 10;
ll f[mac];
int main()
{
	IOS;
	ll n;
	cin >> n;
	int i = 1;
	f[0] = 1, f[1] = 2;
	while (f[i] < inf) {
		i++;
		f[i] = f[i - 1] + f[i - 2];
	}
	i = 1;
	while (n >= f[i]) {
		i++;
	}
	cout << i - 1 << endl;
	return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值