Opposite Task

This problem gives you a flavor the concept of special judge. That means the judge is smart enough to verify your code even though it may print different results. In this problem you are asked to find the opposite task of the previous problem.

To be specific, I have two computers where I stored my problems. Now I know the total number of problems is n. And there are no duplicate problems and there can be at most 10 problems in each computer. You have to find the number of problems in each of the computers.

Since there can be multiple solutions. Any valid solution will do.

Input

Input starts with an integer T (≤ 25), denoting the number of test cases.

Each case starts with a line containing an integer n (0 ≤ n ≤ 20) denoting the total number of problems.

Output

For each case, print the number of problems stored in each computer in a single line. A single space should separate the non-negative integers.

Sample Input

3

10

7

7

Sample Output

0 10

0 7

1 6

分析:题目读了好久才明白,就是求解一个数的和的可能的组合,两个注意点:一、每个数最大10,二、因为对于任何的组合都可以,所以要产生随机数,随机数的大小和每个数组合的个数有关。

上代码:

import java.util.*;
 public class Main{
    static Scanner in=new Scanner(System.in);
    static List st = new ArrayList();
    //计算组合的种类
    static void solve(int n,int a){
      int b;
      while(a!=n/2+1){
  	    b = n-a;
  	    solu s =new solu();
  	    s.n1 = a;
  	    s.n2 = b;
  	    st.add(s);
  	    a++;
       }
    }
    public static void main(String args[]){ 
        int k=in.nextInt();  
        //当n大于10的时候,组合的个数,直接算了方便取
        int[] ran = {0,5,5,4,4,3,3,2,2,1,1};
        while(k-->0){	
        	st.clear();
           int n = in.nextInt(); 
           int a , r;
           if(n<=10){
        	   a = 0;
        	   solve(n,a);
             r = (int) (Math.random()*(n/2+1));
          }
          else{
        	 a = n - 10;  
        	 solve(n,a);
        	  r = (int) (Math.random()*ran[n-10]);
          }   
           //任何组合都可以,随便取一个即可
           System.out.println(st.get(r).n1+" "+st.get(r).n2);
        }
    }
}
 class solu{
	 int n1;
	 int n2;
}



你可能感兴趣的:(模拟,Java,Opposite,Task)