zoukankan      html  css  js  c++  java
  • 计算机学院大学生程序设计竞赛(2015’12)The Magic Tower

    The Magic Tower

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 2382    Accepted Submission(s): 615


    Problem Description
    Like most of the RPG (role play game), “The Magic Tower” is a game about how a warrior saves the princess. 
    After killing lots of monsters, the warrior has climbed up the top of the magic tower. There is a boss in front of him. The warrior must kill the boss to save the princess.
    Now, the warrior wants you to tell him if he can save the princess.
     

    Input
    There are several test cases.
    For each case, the first line is a character, “W” or “B”, indicating that who begins to attack first, ”W” for warrior and ”B” for boss. They attack each other in turn. 
    The second line contains three integers, W_HP, W_ATK and W_DEF. (1<=W_HP<=10000, 0<=W_ATK, W_DEF<=65535), indicating warrior’s life point, attack value and defense value. 
    The third line contains three integers, B_HP, B_ATK and B_DEF. (1<=B_HP<=10000, 0<=B_ATK, B_DEF<=65535), indicating boss’s life point, attack value and defense value. 

    Note: warrior can make a damage of (W_ATK-B_DEF) to boss if (W_ATK-B_DEF) bigger than zero, otherwise no damage. Also, boss can make a damage of (B_ATK-W_DEF) to warrior if (B_ATK-W_DEF) bigger than zero, otherwise no damage. 
     

    Output
    For each case, if boss’s HP first turns to be smaller or equal than zero, please print ”Warrior wins”. Otherwise, please print “Warrior loses”. If warrior cannot kill the boss forever, please also print ”Warrior loses”.
     

    Sample Input
    W 100 1000 900 100 1000 900 B 100 1000 900 100 1000 900
     

    Sample Output
    Warrior wins Warrior loses
     

    总是望着曾经的空间发呆,那些说好不分开的朋友不在了,转身,陌路。 熟悉的,安静了, 安静的,离开了, 离开的,陌生了, 陌生的,消失了, 消失的,陌路了。快哭了

    #include <stdio.h>
    #include <stdlib.h>
    int main()
    {
        char a;
        int i,W_HP,W_ATK,W_DEF,B_HP,B_ATK,B_DEF,w_b,b_w;
        while(~scanf("%c",&a))
        {
            scanf("%d%d%d%d%d%d%*c",&W_HP,&W_ATK,&W_DEF,&B_HP,&B_ATK,&B_DEF);
            w_b=W_ATK-B_DEF;        //w对b每一次攻击的数值
            if(w_b<0) w_b=0;
            b_w=B_ATK-W_DEF;        //b对w每一次攻击的数值
            if(b_w<0) b_w=0;
            if(a=='W')
            {
                for(i=1;i>=1;i++)
                {
                    if(w_b==0)
                    {
                        printf("Warrior loses
    ");
                        break;
                    }
                    B_HP-=w_b;
                    if(B_HP<0)
                    {
                        printf("Warrior wins
    ");
                        break;
                    }
                    W_HP-=b_w;
                    if(W_HP<0)
                    {
                        printf("Warrior loses
    ");
                        break;
                    }
                }
            }
            if(a=='B')
            {
                for(i=1;i>=1;i++)
                {
                    if(w_b==0)
                    {
                        printf("Warrior loses
    ");
                        break;
                    }
                    W_HP-=b_w;
                    if(W_HP<0)
                    {
                        printf("Warrior loses
    ");
                        break;
                    }
                    B_HP-=w_b;
                    if(B_HP<0)
                    {
                        printf("Warrior wins
    ");
                        break;
                    }
                }
            }
        }
        return 0;
    }
    

    @执念  "@☆但求“❤”安★ 下次我们做的一定会更好。。。。吐舌头

    为什么这次的题目是英文的。。。。QAQ...哭

    ------------------- 这是千千的个人网站哦! https://www.dreamwings.cn -------------------
  • 相关阅读:
    P4910 帕秋莉的手环
    P3216 [HNOI2011]数学作业
    洛谷 P2894 [USACO08FEB]酒店
    [网络流24题]魔术球问题
    [网络流24题]飞行员配对方案问题
    [网络流24题]最小路径覆盖问题
    洛谷 P1503鬼子进村
    BZOJ 3631: [JLOI2014]松鼠的新家
    洛谷 P2922 [USACO08DEC]秘密消息Secret Message
    洛谷 P1379 八数码难题
  • 原文地址:https://www.cnblogs.com/im0qianqian/p/5989694.html
Copyright © 2011-2022 走看看