csust-8.11早训CF之1100-1500分

目录

 

A - Nearest Minimums

B - Two Cakes

C - Three Garlands

D - Div. 64

E - Cubes for Masha

F - Solution for Cube


A - Nearest Minimums

 CodeForces - 911A 

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

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false)
const int mac = 2e5 + 10;
const int inf = 1e9 + 10;
int a[mac];
int main()
{
	IOS;
	int n;
	cin >> n;
	int mi = inf;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (mi > a[i]) mi = a[i];
	}
	int dis = inf, mark = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] == mi && mark == 0) mark = i;
		else if (a[i] == mi) dis = min(dis, i - mark), mark = i;
	}
	cout << dis << endl;
	return 0;
}

B - Two Cakes

 CodeForces - 911B 

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

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false)
const int mac = 2e5 + 10;
const int inf = 1e9 + 10;
int main()
{
	IOS;
	int n, a, b, mark = 0;
	cin >> n >> a >> b;
	if (a > b) swap(a, b);
	for (int i = a; i >= 1; i--) {
		int sum = 0, flag = 0; mark = 0;
		for (int j = 1; j <= n; j++) {
			sum += i;
			if (sum > a && mark==0) {
				sum = i; mark = 1;
			}
			if (sum > b && mark) { flag = 1; break; }
		}
		if (!flag) {
			cout << i << endl; return 0;
		}
	}

	return 0;
}

C - Three Garlands

 CodeForces - 911C 

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

//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define IOS ios::sync_with_stdio(false)
const int mac = 2e5 + 10;
const int inf = 1e9 + 10;
int vis[12];
int main()
{
	IOS;
	int k1, k2, k3;
	cin >> k1 >> k2 >> k3;
	vis[k1]++; vis[k2]++; vis[k3]++;
	if (vis[1]) cout << "YES" << endl;
	else if (vis[2] >= 2) cout << "YES" << endl;
	else if (vis[3] >= 3) cout << "YES" << endl;
	else if (vis[2] && vis[4] >= 2) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

D - Div. 64

 CodeForces - 887A 

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

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false)
const int mac = 2e5 + 10;
const int inf = 1e9 + 10;
char s[150];
int main()
{
	IOS;
	cin >> s;
	int len = strlen(s);
	int p;
	for (int i = 0; i < len; i++) {
		p = len - 1 - i;
		if (p < 6) break;
		if (s[i] == '1' && p >= 6) {
			int ss = 0;
			for (int j = i + 1; j < len; j++) {
				if (s[j] == '0') ss++;
			}
			if (ss >= 6) cout << "yes" << endl;
			else cout << "no" << endl;
			return 0;
		}
	}
	cout << "no" << endl;
	return 0;
}

E - Cubes for Masha

 CodeForces - 887B 

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

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false)
const int mac = 2e5 + 10;
const int inf = 1e9 + 10;
int a[10][10], vis[10], n;
int vt[10][12];
int ok(int x);
int main()
{
	IOS;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= 6; j++)
			cin >> a[i][j], vis[a[i][j]] = 1, vt[i][a[i][j]] = 1;
	}
	int i = 1; 
	if (!ok(1)) {
		cout << 0 << endl; return 0;
	}
	while (1) {
		if (ok(i))i++;
		else break;
	}
	cout << i - 1 << endl;
	return 0;
}
int ok(int x)
{
	if (x >= 1000) return 0;
	int v[12];
	memset(v, 0, sizeof(v));
	if (x < 10) {
		if (vis[x]) return 1;
		return 0;
	}
	else if (x >= 10 && x < 100) {
		v[1] = x % 10; x /= 10;
		v[2] = x % 10; x /= 10;	
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				if (i == j) continue;
				if (vt[i][v[1]] && vt[j][v[2]]) return 1;
			}
		}
	}
	else {
		v[1] = x % 10; x /= 10;
		v[2] = x % 10; x /= 10;
		v[3] = x % 10; x /= 10;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				if (i == j) continue;
				for (int k = 1; k <= n; k++) {
					if (i == k || j == k) continue;
					if (vt[i][v[1]] && vt[j][v[2]] && vt[k][v[3]]) return 1;
				}
			}
		}
	}
	return 0;
}

F - Solution for Cube

 CodeForces - 887C 

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值