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: 386ms
Memory: 1092kB
Author: lucy
In contest: 1084

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int main(void){
	int t,i,j; 
	scanf("%d",&t);
	while(t--){
		 int n,flag,count,tempx,tempy,pass;
		 int x[10000],y[10000];
		 scanf("%d",&n);
		 flag=0;count=0;
		 for(i=0;i*2<=n;i++){
			 for(j=0;j*3<=n;j++){
				 if(i*2+j*3==n){
					 x[count]=i;y[count]=j;
					 count++;
					 flag=1;
				 }
			 }
		 }
			 if(flag==0)
				 printf("WA\n");
			 if(flag==1){
				 for(pass=1;pass<count;++pass){
					 for(i=0;i<count-pass;++i){
						 if(x[i]>x[i+1]){
							 tempx=x[i];
							 x[i]=x[i+1];
							 x[i+1]=tempx;
							  tempy=y[i];
							 y[i]=y[i+1];
							 y[i+1]=tempy;
						 }
					 }
				 }
				 printf("%d %d\n",x[0],y[0]);

			 }
	}
	return 0;
}