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 }
  • 相关阅读:
    (转)const变量通过指针修改问题
    sleep wait yeild join
    做事贵在坚持
    我的学习进度
    织梦dedecms后台添加图片style全部都变成st<x>yle的解决办法
    调用DEDE日期时间格式整理大全
    Arcgis andoid开发之应用百度地图接口实现精准定位与显示
    jquery自定义插件——window的实现
    lzugis—搭建属于自己的小型的版本控制SVN
    lzugis——Arcgis Server for JavaScript API之自定义InfoWindow
  • 原文地址:https://www.cnblogs.com/cnblogs321114287/p/4438683.html
Copyright © 2011-2022 走看看