acwing 第 31 场周赛

题目传送门

链接:https://www.acwing.com/activity/content/competition/problem_list/86/

4200. 简单问题

#include <bits/stdc++.h>
using namespace std;

int main(void)
{
    int t, p = 1001, a, b;
    for (int i = 0; i < 4; i++) {
        cin >> t;
        p = min(p, t);
    }
    cin >> a >> b;
    int res = 0;
    for (int i = a; i <= b; i++) {
        if (i < p) res++;
    }
    cout << res << endl;
    
    return 0;
}

4201. 01数

dfs枚举

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int res = 0, n;

void dfs(int u, ll state) 
{
    if (state > n)
        return;
    res++;
    //cout << state << endl;
    dfs(u + 1, state * 10);
    dfs(u + 1, state * 10 + 1);
}

int main(void)
{
    cin >> n;
    dfs(0, 1);
    cout << res << endl;
    
    return 0;
}

4202. 穿过圆

答案为等于 包围点a但不包围点b的圆 + 包围点b但不包围点a的圆

用一个bitset来维护点和圆的关系

arr[i][j] = 1表示第i个点被第j个圆包围

答案为(arr[a] ^ arr[b]).count()

Qrz

#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
#define debug(x) cout << #x << " = " << x << endl;

struct point{int x, y;};
struct circle{int r, x, y;};

int n, m, k;
point p[N];
circle c[N];
bitset<N> arr[N];

bool check(int a, int b)
{
    double x = p[a].x - c[b].x;
    double y = p[a].y - c[b].y;
    
    return sqrt(x * x + y * y) - c[b].r < 1e-6;
}

int main(void)
{
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++) {
        cin >> p[i].x >> p[i].y;
    }
    for (int i = 1; i <= m; i++) {
        cin >> c[i].r >> c[i].x >> c[i].y;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (check(i, j)) arr[i].set(j);
        }
    }
    int a, b;
    while (k--) {
        scanf("%d%d", &a, &b);
        printf("%d\n", (arr[a] ^ arr[b]).count());
    }
    
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值