Codeforces Round 883 (Div. 3) VP记录

A

很明显找落下来会碰到地的钉子有多少即可

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define haha cout<<"\n"
#define ye cout<<"Yes\n"
#define no cout<<"No\n"
typedef unsigned long long ull;
const int N = 1e6 + 10;
const int M = 10100;
const int mod = 998244353;
const double eps = 1e-8;
double pi = acos(-1);
int dx[10] = {-1, 0, 1, 0};
int dy[10] = {0, 1, 0, -1};
int n, m, k;
int ksm(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1)
			ans = ans * x;
		y >>= 1;
		x = x * x;
	}
	return ans;
}
struct node {
	int a, b;
} a[N];

void solve() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i].a >> a[i].b;
	}
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i].a > a[i].b)
			cnt++;
	}
	cout << cnt << '\n';
}
signed main() {
//	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t = 1;
//	init();
	cin >> t;
	while (t--)
		solve();
	return 0;
}
/*
13 5
13
*/

B

暴力遍历

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define haha cout<<"\n"
#define ye cout<<"Yes\n"
#define no cout<<"No\n"
typedef unsigned long long ull;
const int N = 1e6 + 10;
const int M = 10100;
const int mod = 998244353;
const double eps = 1e-8;
double pi = acos(-1);
int dx[10] = {-1, 0, 1, 0};
int dy[10] = {0, 1, 0, -1};
int n, m, k;
int ksm(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1)
			ans = ans * x;
		y >>= 1;
		x = x * x;
	}
	return ans;
}
char a[10][10];

void solve() {
	for (int i = 1; i <= 3; i++) {
		for (int j = 1; j <= 3; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 1; i <= 3; i++) {
		char x = a[i][1];
		if (x == '.') continue;
		int f = 0;
		for (int j = 1; j <= 3; j++) {
			if (a[i][j] != x) {
				f = 1;
			}
		}
		if (f == 0) {
			cout << x << '\n';
			return;
		}
	}
	for (int i = 1; i <= 3; i++) {
		char x = a[1][i];
		if (x == '.') continue;
		int f = 0;
		for (int j = 1; j <= 3; j++) {
			if (a[j][i] != x) {
				f = 1;
			}
		}
		if (f == 0) {
			cout << x << '\n';
			return;
		}
	}
	if (a[1][1] != '.' && a[1][1] == a[2][2] && a[1][1] == a[3][3]) {
		cout << a[1][1] << '\n';
		return;
	}
	if (a[1][3] != '.' && a[1][3] == a[2][2] && a[1][3] == a[3][1]) {
		cout << a[1][3] << '\n';
		return;
	}
	cout << "DRAW\n";
}
signed main() {
//	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t = 1;
//	init();
	cin >> t;
	while (t--)
		solve();
	return 0;
}
/*
13 5
13
*/

C

排序模拟即可,因为罚时计算错误喜提罚时

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define haha cout<<"\n"
#define ye cout<<"Yes\n"
#define no cout<<"No\n"
typedef unsigned long long ull;
const int N = 1e6 + 10;
const int M = 10100;
const int mod = 998244353;
const double eps = 1e-8;
double pi = acos(-1);
int dx[10] = {-1, 0, 1, 0};
int dy[10] = {0, 1, 0, -1};
int n, m, k;
int ksm(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1)
			ans = ans * x;
		y >>= 1;
		x = x * x;
	}
	return ans;
}
char a[10][10];

void solve() {
	int h;
	cin >> n >> m >> h;
	vector<int> v;
	for (int i = 1; i <= m; i++) {
		int x;
		cin >> x;
		v.push_back(x);
	}
	int sum = 0;
	sort(v.begin(), v.end());
	int cnt = 0;
	int y = 0;
	for (int i = 0; i < v.size(); i++) {
		int t = v[i];
		if (y + t <= h) {
			sum = sum + y + t;
			cnt++;
			y += t;
		}
	}
	v.clear();
//	cout << sum << ' ' << cnt << '\n';
	int ans = 1;
	for (int i = 2; i <= n; i++) {
		vector<int> v;
		int sum1 = 0;
		int cnt1 = 0, y = 0;
		for (int j = 1; j <= m; j++) {
			int x;
			cin >> x;
			v.push_back(x);
		}
		sort(v.begin(), v.end());
		for (int i = 0; i < v.size(); i++) {
			if (y + v[i] <= h) {
				sum1 = sum1 + y + v[i];
				cnt1++;
				y += v[i];
			}
		}
//		cout << cnt1 << ' ' << sum1 << '\n';
		if (cnt1 > cnt) ans++;
		else if (cnt1 == cnt) {
			if (sum1 < sum) ans++;
		}
		v.clear();
	}
	cout << ans << '\n';
}
signed main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t = 1;
//	init();
	cin >> t;
	while (t--)
		solve();
	return 0;
}
/*
13 5
13
*/

D

计算几何题,关键在于计算底的长度,我用到了相似三角形,算面积的时候应该计算\(总面积-被遮盖面积\)更加好写

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define haha cout<<"\n"
#define ye cout<<"Yes\n"
#define no cout<<"No\n"
typedef unsigned long long ull;
const int N = 1e6 + 10;
const int M = 10100;
const int mod = 998244353;
const double eps = 1e-8;
double pi = acos(-1);
int dx[10] = {-1, 0, 1, 0};
int dy[10] = {0, 1, 0, -1};
int n, m, k;
int ksm(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1)
			ans = ans * x;
		y >>= 1;
		x = x * x;
	}
	return ans;
}
double a[N];
void solve() {
	double m, h;
	cin >> n >> m >> h;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	double sum = 0;
	//(a[i] + h - a[i + 1]) * m / h
	double a1 = m * h * 0.5;
	for (int i = 1; i < n; i++) {
		if (a[i + 1] - a[i] < h) {
			double s1 = ( ( a[i] + h - a[i + 1] ) * m / h) * 0.5 * (a[i] + h - a[i + 1]);
//			cout << s1 << '\n';
			sum += s1;
		}
	}
	double ans = a1 * n;
//	printf("%.8lf\n", ans);
//	printf("%.8lf\n", sum);
	printf("%.8lf\n", ans - sum);
}
signed main() {
//	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t = 1;
//	init();
	cin >> t;
	while (t--)
		solve();
	return 0;
}
/*
13 5
13
*/

E1

题目比较难懂,实际需要预处理和一些树论的知识将可能的点全部求出即可。题意:是否存在n个结点的满k叉树。

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define haha cout<<"\n"
#define ye cout<<"Yes\n"
#define no cout<<"No\n"
typedef unsigned long long ull;
const int N = 1e6 + 10;
const int M = 10100;
const int mod = 998244353;
const double eps = 1e-8;
double pi = acos(-1);
int dx[10] = {-1, 0, 1, 0};
int dy[10] = {0, 1, 0, -1};
int n, m, k;
int ksm(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1)
			ans = ans * x;
		y >>= 1;
		x = x * x;
	}
	return ans;
}
double a[N];
map<int, bool> st;
void init() {
	int sum;
	for (int i = 2; i <= 1000; i++) {
		sum = 1;
		for (int j = 1; j <= 20; j++) {
			int kk = 1;
			for (int k = 1; k <= j; k++) kk *= i;
			sum += kk;
			if (sum >= 1e7) break;
			if (j >= 2) st[sum] = 1;
		}
	}
}
void solve() {
	cin >> n;
	if (n <= 5) {
		no;
		return;
	}
	if (st[n] == 1)
		ye;
	else
		no;
}
signed main() {
//	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t = 1;
	init();
	cin >> t;
	while (t--)
		solve();
	return 0;
}
/*
13 5
13
*/

vp名次还可以。

posted @ 2024-07-05 17:49  ZhangDT  阅读(2)  评论(0编辑  收藏  举报