Start: Jan, 04, 2017 19:40:00
2016年秋季学期程序设计基础期末考试
End: Jan, 04, 2017 21:40:00
Time elapsed:
Time remaining:

Problem_ID: F
Result: Accepted
Time: 372ms
Memory: 1092kB
Author: YuChen06304323
In contest: 1084

#include<stdio.h>
int main(){
	int T,i;
	int j,k;
	int amount;
	int x[10000];
	int y[10000];
	int MIN;
	int count;
	scanf("%d",&T);
	for(i = 1 ; i <= T ; ++ i){
		count = 0;
		scanf("%d",&amount);
		if(amount != 0){
		for(j = 0 ; j <= amount / 3 ; ++ j){
			for(k = 0 ; k <= amount / 2 ; ++ k){
				if((j * 3 + k * 2) == amount){
					x[count] = k;
					y[count] = j;
					count ++;
				}
			}
		}
		if(count == 0)
			printf("WA\n");
		else if(count > 1){
			MIN = x[0];
			for(k = 0 ; k < count ; ++ k)
				if(MIN > x[k])
					MIN = x[k];
			for(k = 0 ; k < count ; ++ k)
				if(MIN == x[k])
					printf("%d %d\n",x[k],y[k]);
		}
		else
			printf("%d %d\n",x[0],y[0]);
	}
		else
			printf("0 0\n");
	}
	return 0;
}