觉得浮夸了四年,漠然发现原来是浮躁了四年!

hdu 4461(The Power of Xiangqi)

Problem webpage:

http://acm.hdu.edu.cn/showproblem.php?pid=4461

Problem analysis:
This is one of the 2012 Asia Hangzhou Regional Contest problems, what I want to say is this problem is just proved that you joined the contest;

The only problem is the problem description is too long>

After reading the problem description, you will find it's so easy;

 

View Code
#include<stdio.h>
#include<string.h>
int canon,horse;
int power(char x)
{
    int p;
    if(x=='A')
        p=16;
    else if(x=='B')
    {
        p=7;
        horse=1;
    }
    else if(x=='C')
    {
        p=8;
        canon=1;
    }
    else if(x=='D')
        p=1;
    else if(x=='E')
        p=1;
    else if(x=='F')
        p=2;
    else
        p=3;
    return p;
}

int main()
{
    int n,num1,num2,i,j;
    char  red[20],black[20];
    
    int sum_red,sum_black;
    scanf("%d",&n);
    while(n--)
    {
        canon=horse=0;
        sum_red=sum_black=0;
        scanf("%d",&num1);
        for(i=0;i<num1;i++)
            scanf(" %c",&red[i]);
        scanf("%d",&num2);
        for(j=0;j<num2;j++)
            scanf(" %c",&black[j]);
        for(i=0;i<num1;i++)
            sum_red+=power(red[i]);
        if(horse==0||canon==0)
            sum_red-=1;
        horse=canon=0;
        for(j=0;j<num2;j++)
            sum_black+=power(black[j]);
        if(horse==0||canon==0)
            sum_black-=1;
        if(sum_red==sum_black)
            printf("tie\n");
        else if(sum_red>sum_black)
            printf("red\n");
        else if(sum_red<sum_black)
            printf("black\n");
    }
    return 0;
}






        

 

 

posted @ 2012-11-09 19:20  heat nan  阅读(111)  评论(0)    收藏  举报