View Code of Problem 124

import java.util.*;
class teem{
	int self;
	int point=0;
}
public class Main {
	 public static void main(String[] args) {
		 Scanner in = new Scanner(System.in);
		 int t = in.nextInt();
		 for(int i =0;i<t;i++) {
			 int n=in.nextInt();
			 int m=in.nextInt();
			 int win = in.nextInt();
			 int equal= in.nextInt();
			 int lose = in.nextInt();
			 int[][] allmatch = getnum(0,n-1,2);
			 ArrayList<teem> AL = new ArrayList<teem>();
			 for(int j =0;j<n;j++) {
				 teem tm = new teem();
				 tm.self=j;
				 AL.add(tm);
			 }
		 }
	 }
	 public static int C(int m,int n) {
			double s=1; 
			for(int i =0;i<n;i++) {
				s=s*(m--)/(i+1);
			}
			return (int)s;
		}
		public static boolean have(int[] arr,int n) {
			for(int i :arr) {
				if(i==n) {
					return true;
				}
			}
			return false;
		}
		public static int[][] getnum(int a,int b,int n) {
			int[][] aal = new int[C(b-a+1,n)][n];
			if(n==1) {
				for(int i =a;i<=b;i++) {
					int[] al = new int[n];
					al[0]=i;
					aal[i-a]=al;
				}
			}else {
				int count = 0;
				int[][] tinyaal = getnum(a,b,n-1);
				for(int i =a;i<=b-n+1;i++) {
					int[] al = new int[n];
					al[0]=i;			
					for(int[] AL :tinyaal) {
						if(AL[0]>i) {
							for(int j =0;j<AL.length;j++) {
								al[j+1]=AL[j];
							}
							aal[count++]=al.clone();						
						}
					}
				}
			}
			return aal;
		}
	 public static int mininthree(int a,int b,int c) {
		 int temp = a<b?a:b;
		 int max = temp<c?temp:c;
		 return max;
	 }
	 public static int maxinthree(int a,int b,int c) {
		 int temp = a>b?a:b;
		 int max = temp>c?temp:c;
		 return max;
	 }
}

Double click to view unformatted code.


Back to problem 124