Monday, October 17, 2011

[UVa] 278 - Chess

Analyze all 4 cases and soon you'll equations for all of them. The given advantage is the lower limit of 4. Below that the derived theorems fail.

#include <stdio.h>
#include <string.h>
#define min(a,b) (a<b?a:b)
char inp[100];
int main()
{
    int test, x, y;
    char a;
    scanf("%d",&test);
    getchar();
    while (test--)
    {
        gets(inp);


        sscanf(inp,"%c %d %d",&a,&x,&y);
        if (a=='k')
        {
            printf("%d\n",(x*y+1)/2);
        } else if (a=='K')
        {
            printf("%d\n",((x+1)/2) * ((y+1)/2));
        } else if (a=='Q'||a=='r')
        {
            printf("%d\n",min(x,y));
        }
    }
    return 0;
}

No comments:

Post a Comment

Post your comment here. If you want to say something about programming problems, scripts, software etc, please try to be as descriptive as possible.

Connect Rapoo MT750S with Linux (Tested on Manjaro)

 I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...