zoukankan      html  css  js  c++  java
  • hdu 4461 第37届ACM/ICPC杭州赛区I题

    题意:给两个人一些棋子,每个棋子有其对应的power,若b没有或者c没有,或者二者都没有,那么他的total power就会减1,total power最少是1,求最后谁能赢

    如果b或c出现的话,flag就标记为1,那么在判断的时候如果flag==0,就说明他们没出现过,那么就要-1,然后就wa了,必须要两个变量判断,不知道为什么

     1 #include<cstdio>
     2 #include<iostream>
     3 #include<algorithm>
     4 #include<cstring>
     5 #include<cmath>
     6 #include<queue>
     7 #include<map>
     8 using namespace std;
     9 #define MOD 1000000007
    10 const int INF=0x3f3f3f3f;
    11 const double eps=1e-5;
    12 #define cl(a) memset(a,0,sizeof(a))
    13 #define ts printf("*****
    ");
    14 const int MAXN=1005;
    15 int n,m,tt;
    16 int main()
    17 {
    18     int i,j,k;
    19     #ifndef ONLINE_JUDGE
    20     freopen("1.in","r",stdin);
    21     #endif
    22     scanf("%d",&tt);
    23     while(tt--)
    24     {
    25         scanf("%d",&n);
    26         char c[10];
    27         int flag=0,ma=0,pao=0;
    28         int sum1=0,sum2=0;
    29         for(i=1;i<=n;i++)
    30         {
    31             scanf("%s",c);
    32             if(c[0]=='A')  sum1+=16;
    33             else if(c[0]=='B') sum1+=7,ma=true;
    34             else if(c[0]=='C') sum1+=8,pao=true;
    35             else if(c[0]=='D') sum1+=1;
    36             else if(c[0]=='E') sum1+=1;
    37             else if(c[0]=='F') sum1+=2;
    38             else if(c[0]=='G') sum1+=3;
    39         }
    40         if((!ma)||(!pao))
    41             if(sum1>1)sum1-=1;
    42         flag=0;
    43         ma=false,pao=false;
    44         scanf("%d",&n);
    45         for(i=1;i<=n;i++)
    46         {
    47             scanf("%s",c);
    48             if(c[0]=='A')  sum2+=16;
    49             else if(c[0]=='B') sum2+=7,ma=true;
    50             else if(c[0]=='C') sum2+=8,pao=true;
    51             else if(c[0]=='D') sum2+=1;
    52             else if(c[0]=='E') sum2+=1;
    53             else if(c[0]=='F') sum2+=2;
    54             else if(c[0]=='G') sum2+=3;
    55         }
    56         if((!ma)||(!pao))
    57             if(sum2>1)sum2-=1;
    58         if(sum1==sum2)  printf("tie
    ");
    59         else if(sum1>sum2)  printf("red
    ");
    60         else printf("black
    ");
    61     }
    62     return 0;
    63 }
  • 相关阅读:
    javascript Date类的扩展
    软件工程师好了歌 (转)
    您可能不知道的.Net2.0小技巧
    您未必知道的Js技巧
    复活吧,架构师!
    技巧系列文章
    不要使用paddingtop控制内容开始的位置
    JQuery Offset实验与应用(转载)
    2008最佳Windows应用程序
    精选15个国外CSS框架
  • 原文地址:https://www.cnblogs.com/cnblogs321114287/p/4438683.html
Copyright © 2011-2022 走看看