写了ABC三个水题..
A: 126 136 124 三种组合判断是否够用
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const double PI = acos(-1.0);
template <class T> inline T MAX(T a, T b){if (a > b) return a;return b;}
template <class T> inline T MIN(T a, T b){if (a < b) return a;return b;}
const int N = 111;
const int M = 11111;
const LL MOD = 1000000007LL;
const int dir[4][2] = {1, 0, -1, 0, 0, -1, 0, 1};
const int INF = 0x3f3f3f3f;
int cnt[10];
int ans[10];
int main()
{
int n;
scanf("%d", &n);
memset(cnt, 0, sizeof(cnt));
int i, j, k;
for (i = 0; i < n; ++i)
{
scanf("%d", &k);
cnt[k]++;
}
if (cnt[5] != 0 || cnt[7] != 0) {printf("-1\n"); return 0;}
ans[0] = cnt[4];
if (cnt[1] < cnt[4] || cnt[2] < cnt[4]) {printf("-1\n"); return 0;}
cnt[1] -= cnt[4]; cnt[2] -= cnt[4];
if (cnt[1] != cnt[6] || cnt[2] + cnt[3] != cnt[6]) {printf("-1\n"); return 0;}
ans[1] = cnt[3]; ans[2] = cnt[2];
for (i = 0; i < ans[0]; ++i)
{
printf("1 2 4\n");
}
for (i = 0; i < ans[1]; ++i)
printf("1 3 6\n");
for (i = 0; i < ans[2]; ++i)
printf("1 2 6\n");
return 0;
}
B:只要能够靠近就移动就行
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const double PI = acos(-1.0);
template <class T> inline T MAX(T a, T b){if (a > b) return a;return b;}
template <class T> inline T MIN(T a, T b){if (a < b) return a;return b;}
const int N = 111;
const int M = 11111;
const LL MOD = 1000000007LL;
const int dir[4][2] = {1, 0, -1, 0, 0, -1, 0, 1};
const int INF = 0x3f3f3f3f;
int t[111111], l[111111], r[111111];
int main()
{
int s, f, n, m, i, j, k, pos, now = 1;
pos = 0;
scanf("%d%d%d%d", &n, &m, &s, &f);
for (i = 0; i < m; ++i)
scanf("%d%d%d", &t[i], &l[i], &r[i]);
if (s > f)
{
pos = s;
for (i = 0; ;)
{
// printf("%d %d\n", i, now);
if (now != t[i])
{
now++;putchar('L');
pos--;
if (pos == f)
{
break;
}
continue;
}
now++;
if ((l[i] <= pos && r[i] >= pos) || (l[i] <= pos - 1 && r[i] >= pos - 1))
{putchar('X');}
else
{
putchar('L');
pos--;
}
if (pos == f)
{
break;
}
i++;
}
}
else
{
pos = s;
for (i = 0; ;)
{
// printf("%d %d\n", i, now);
if (now != t[i])
{
now++;putchar('R');
pos++;
if (pos == f)
{
break;
}
continue;
}
now++;
if ((l[i] <= pos && r[i] >= pos) || (l[i] <= pos + 1 && r[i] >= pos + 1))
{putchar('X');}
else
{
putchar('R');
pos++;
}
if (pos == f)
{
break;
}
i++;
}
}
printf("\n");
return 0;
}
C:
顶部半圆分三种情况 剩余高度大于sqrt(3) * r / 2, 大于 r / 2 大于等于0即可
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const double PI = acos(-1.0);
template <class T> inline T MAX(T a, T b){if (a > b) return a;return b;}
template <class T> inline T MIN(T a, T b){if (a < b) return a;return b;}
const int N = 111;
const int M = 11111;
const LL MOD = 1000000007LL;
const int dir[4][2] = {1, 0, -1, 0, 0, -1, 0, 1};
const int INF = 0x3f3f3f3f;
int main()
{
int h, r;
scanf("%d%d", &r, &h);
double k = sqrt(3.0);
int s = h % r, ans = h / r * 2;
double rest = s;
if (rest >= k * r / 2.0) ans += 3;
else if (rest >= r / 2.0) ans += 2;
else ans++;
printf("%d\n", ans);
return 0;
}