目录
A - Nearest Minimums
题目链接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
题目链接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
题目链接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
题目链接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
题目链接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;
}