Dick and Jane

 题目连接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1110 这道题听搞怪, 一下子还真不好想
四个表达式: a-b = s || s+1
b-c = p || p+1
a-c = y || y+1
a+b+c = 12 + j
#include "math.h"
 
int main(){
    int Spot, Puff, Yertle, Jane, S, P, Y, J;
    while(scanf("%d %d %d %d", &S, &P, &Y, &J) != EOF){
        int temp = (J + 12 - Y - P ) % 3;
        Yertle = (J + 12 - Y - P ) / 3;
        if(temp == 0 ){
            printf("%d %d %d\n", Yertle + Y, Yertle + P, Yertle);
        }
        else if(temp == 2){
            printf("%d %d %d\n", Yertle + Y + 1, Yertle + P + 1, Yertle);
        }
        else{
            if(P+S==Y)
                printf("%d %d %d\n", Yertle + Y + 1, Yertle + P, Yertle);
            else
                printf("%d %d %d\n", Yertle + Y, Yertle + P + 1, Yertle);
        }
    }
    return 0;
}


你可能感兴趣的:(ACM,ACM)