Code forces 199 div 2 A B C

写了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;
}


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值