Seventh annual Blue Bridge Cup competition--Xiao Ming was kidnapped by the wizard W of Planet X.

Source: Internet
Author: User
Tags ming
Xiao Ming was kidnapped by the wizard W of Planet X.
at the time, W is toying with two sets of data (2 3 5 8) and (1 4 6 7)
He ordered Xiao Ming to match the number from one set of data to another in a group of 4 pairs (each number in the group must be used).
Xiao Ming's Matching method is: {(8,7), (5,6), (3,4), (2,1)} The
sorcerer stares for a moment, suddenly said that this method is wonderful.
because:
the number in each pairing consists of two digits, squared sum, whether it is inverted, incredibly equal:
87^2 + 56^2 + 34^2 + 21^2? = 12302 78^2
+ 65^2 + 43^2 + 12^2? =? 12302
Xiao Ming thought to say: "This is what is strange, we all the Earth people know, casually match also can ah." "
{(8,6), (5,4), (3,1), (2,7)}
86^2 + 54^2 + 31^2 + 27^2 = 12002
68^2 + 45^2 + 13^2 + 72^2 = 12002
The wizard was suddenly messy. 。。。。。
please calculate, including the two methods given above, wizards of the two sets of data on how many kinds of pairing scheme has this feature. Pairing
scenarios are counted regardless of the order in which they appear.
is to say:
{(8,7), (5,6), (3,4), (2,1)}
With
{(5,6), (8,7), (3,4), (2,1)}
is the same scenario.
Note: You need to submit an integer, do not fill in any superfluous content (for example, explanatory text, etc.)

Idea: As long as the number of the two groups of 22 pairs out all combinations, each combination will be calculated! Here is a more stupid method, a group of numbers, the other group lists all permutations, because there is no need to consider the location, so only a set of numbers to list the line!
public class xiaomingbangjia{static int[] arr1 = {2,3,5,8}; static int arr2[][] = {{1,4,6,7},{1,4,7,6},{1,6,4,7},{1,6,7,4},{1,7,4,6},{1,7,6,4}, {4,1,6,7}, {4,1,7,6},{4,6,1,7},{4,6,7,1},{4,7,1,6},{4,7,6,1}, {6,1,4,7},{6,1,7,4},{6,4,1,7},{6,4,7,1},{6,7,1,4},
	
	{6,7,4,1}, {}7,1,4,6},{7,1,6,4},{7,4,1,6},{7,4,6,1},{7,6,1,4},{7,6,4,1}};
	public static void Main (string[] args) {new Xiaomingbangjia (). Fun (Arr1.length,arr1.length);
	
	}//combination number static int s = 0;
		public void Fun (int b, int e) {int arr3[] = new INT[4];
			for (int i=0, i<arr2.length;i++) {for (int j=0; j<arr3.length; J + +) {Arr3[j] = arr1[j]*10 + arr2[i][j];
			} int sum1 = SUM (ARR3);
			int arr4[] = counter (ARR3);
			int sum2 = SUM (ARR4);
				if (sum1==sum2) {s++;
			System.out.println ("currently has" +s+ "kind of Combination" +sum1);
			}else{System.out.println ("We are not the same");
		}}}//array sum public int sum (int arr[]) {int sum = 0; For (int i=0; i<arr.length; i++) {sum = sum + arr[i]*arr[i];
	} return sum;
			}//will array instead public int[] counter (int arr[]) {for (int i=0; i<arr.length; i++) {int num1 = ARR[I]/10;
			int num2 = arr[i]-num1*10;
		Arr[i] = NUM2*10+NUM1;
	} return arr;
 }


	
}
Last Answer: 24





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.