zoukankan      html  css  js  c++  java
  • 模拟赛DAY1 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
    ",p.hp,p.st,p.de);
            }
        }
        return 0;
    }
  • 相关阅读:
    2019安徽省程序设计竞赛 I.你的名字(序列自动机)
    poj3522Slim Span(暴力+Kruskal)
    Uva1349Optimal Bus Route Design(二分图最佳完美匹配)(最小值)
    基于Python的Web应用开发实战——3 Web表单
    [nRF51822]5.触摸按键
    [nRF51822]4.GPIO控制蜂鸣器
    [nRF51822]3. GPIO输入按键检测
    [nRF51822]2. 跑马灯
    [nRF51822]1. 点亮一个LED
    [nRF51822]0.nRF51822的开发环境
  • 原文地址:https://www.cnblogs.com/lcezych/p/11072466.html
Copyright © 2011-2022 走看看