Result: Accepted
Time: 372ms
Memory: 1092kB
#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;
}