網頁

2013年7月7日 星期日

d984: 棄保效應

/**********************************************************************************/
/*  Problem: d984 "棄保效應" from 板橋高中教學題                       */
/*  Language: C (807 Bytes)                                                       */
/*  Result: AC(0ms, 292KB) judge by this@ZeroJudge                                */
/*  Author: monkey413 at 2013-07-06 15:13:30                                      */
/**********************************************************************************/


#include<stdio.h>
#include<stdlib.h>

int compare(const void *a, const void *b){
    return *((long long int*)a+1)-*((long long int*)b+1) ;
}

int main(){
    int lines = 1 ;
    long long int vote[3][2], result;
    int i, j ;
    while(scanf("%lld %lld %lld",&vote[0][1],&vote[1][1],&vote[2][1])==3){
        vote[0][0] = 0 ;
        vote[1][0] = 1 ;
        vote[2][0] = 2 ;
        qsort(vote,3,sizeof(vote[0]),compare) ;
        /*for(i=0 ; i<3 ; ++i){
            printf("%lld %lld \n",vote[i][0],vote[i][1]);
        }*/
        if(vote[0][1]+vote[1][1]>vote[2][1]) result = vote[1][0] ;
        else result = vote[2][0] ;
        switch(result){
            case 0: puts("A") ; break ;
            case 1: puts("B") ; break ;
            case 2: puts("C") ; break ;
        }
    }
    return 0 ;
}

沒有留言:

張貼留言