Day1

汤姆的游戏

题意:给几个长方形和园的数据,再给几个点,求每个点再多少个图形内部,再图形边界上不算再内部。

思路:这个题数据只有500,直接暴力枚举每个点的情况就可以了,在长方形内部的条件就是点的横纵坐标分别满足在长方形长和宽的范围内就可以了(开区间),圆的则是点到圆心的距离小于半径则在内部,按照情况写出代码即可。

#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
using namespace std;
typedef double D;
D X1[510],X2[510],Y1[510],Y2[510];
char op[510];
int n,m;
int cac(D x,D y) {
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (op[i] == 'r') {
            D lx = min(X1[i], X2[i]);
            D rx = max(X1[i], X2[i]);
            D ly = min(Y1[i], Y2[i]);
            D ry = max(Y1[i], Y2[i]);
            if ((x > lx && x < rx) && (y > ly && y < ry))ans++;
        }
        if (op[i] == 'c') {
            D dis = sqrt((x - X1[i]) * (x - X1[i]) + (y - Y1[i]) * (y - Y1[i]));
            if (dis < X2[i])ans++;
        }
    }
    return ans;
}
int main() {
    IOS;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> op[i];
        if (op[i] == 'r')
            cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
        else
            cin >> X1[i] >> Y1[i] >> X2[i];
    }
    for (int i = 0; i < m; i++) {
        D xx, yy;
        cin >> xx >> yy;
        cout << cac(xx, yy) << '\n';
    }
    //for(int i=0;i<n;i++)cout<<op[i]<<' '<<X1[i]<<' '<<Y1[i]<<' '<<X2[i]<<' '<<Y2[i]<<'\n';
    return 0;
}

Day2

大美江湖 就是最简单的模拟,考验码代码的能力,再说代码也不是很长,就是耐心和细心就可以了

#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
using namespace std;
typedef double D;
int n,m;
char g[110][110];
int hp,st,de;
int hp0,st0,de0;
int x,y;

int life(int a,int b,int c){
    int res=ceil((a*1.0)/max(1,st-c));
    int ans=max(1,max(1,b-de)*res);
    return ans;
}

void move(int aa,int bb){
    if(g[aa][bb]=='R'){
        if(hp<=10)hp=0;
        else hp=hp-10;
    }
    if(g[aa][bb]=='Q')st+=5;
    if(g[aa][bb]=='Y')de+=5;
    if(g[aa][bb]=='M')hp+=life(hp0,st0,de0);
}

int main() {
    IOS;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> g[i][j];
    cin >> hp0 >> st0 >> de0;
    cin >> x >> y;
    cin >> st >> de;
    int t;
    cin >> t;
    while (t--) {
        int op;
        cin >> op;
        if (op == 1) {
            cout << hp << ' ' << st << ' ' << de << '\n';
        } else {
            int a;
            cin >> a;
            if (a == 1)y = y - 1;
            if (a == 2)y = y + 1;
            if (a == 3)x = x - 1;
            if (a == 4)x = x + 1;
            move(x, y);
        }
    }
    return 0;
}