校内模拟赛T1大美江湖

 

这就是一个模拟题,注意1234分别对应左右上下横坐标和纵坐标的判断就好了

题解:

 需要注意的是,向上取整ceil函数是对于一个double值返回一个double值,也就是说在ceil里面的类型一定要是double,否则会炸

代码:

#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pr;
const double pi=acos(-1);
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
#define Rep(i,u) for(int i=head[u];i;i=Next[i])
#define clr(a) memset(a,0,sizeof a)
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
ld eps=1e-9;
ll pp=1000000007;
ll mo(ll a,ll pp){if(a>=0 && a<pp)return a;a%=pp;if(a<0)a+=pp;return a;}
ll powmod(ll a,ll b,ll pp){ll ans=1;for(;b;b>>=1,a=mo(a*a,pp))if(b&1)ans=mo(ans*a,pp);return ans;}
int read(){
    int ans=0;
    char last=' ',ch=getchar();
    while(ch<'0' || ch>'9')last=ch,ch=getchar();
    while(ch>='0' && ch<='9')ans=ans*10+ch-'0',ch=getchar();
    if(last=='-')ans=-ans;
    return ans;
}
int n,m;
char atlas[105][105];
int x,y;
int q;
struct part
{
    int hp,st,de;
}p,e;
inline void work(int x,int y)
{
    if(atlas[x][y]=='R')
    {
        p.hp-=10;
        if(p.hp<0) p.hp=0;
    }
    if(atlas[x][y]=='Q')
    {
        p.st+=5;
    }
    if(atlas[x][y]=='Y')
    {
        p.de+=5;
    }
    if(atlas[x][y]=='M')
    {
        double m=double(e.hp)/double(max(1,p.st-e.de));
        int k=ceil(m);
        p.hp+=max(1,k*max(1,e.st-p.de));
    }
}

int main()
{
    freopen("mzq.in","r",stdin);
    freopen("mzq.out","w",stdout);
    n=read(),m=read();
    rep(i,1,n)
    {
        rep(j,1,m+1)
        {
            scanf("%c",&atlas[i][j]);
        }
    }
    e.hp=read(),e.st=read(),e.de=read();
    x=read(),y=read();
    p.st=read(),p.de=read();
    q=read();
    int c=0,a=0;
    rep(i,1,q)
    {
        c=read();
        if(c==2)
        {
            a=read();
            if(a==1)
            {
                y-=1;
                work(x,y);
            }
            if(a==2)
            {
                y+=1;
                work(x,y);
            }
            if(a==3)
            {
                x-=1;
                work(x,y);
            }
            if(a==4)
            {
                x+=1;
                work(x,y);
            }
        } 
        if(c==1)
        {
            printf("%d %d %d\n",p.hp,p.st,p.de);
        }
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/lcezych/p/11072466.html