Describe: |
Write a function, pass in an int array, returns whether the array can be divided into two groups, so that the elements of the two groups are combined and equal, and that all multiples of 5 must be in one group, all multiples of 3 in another group (excluding a multiple of 5), which satisfies the above conditions and returns true , false when not satisfied.
|
Knowledge Points: |
Language basics, strings, loops, functions, pointers, enumerations, bitwise operations, structs, consortia, file operations, recursion |
Topic Source: |
Internal finishing |
Practice phase: |
Primary |
Run time limit: |
10Sec |
Memory Limit: |
128MByte |
Input: |
Enter the number of data entered Enter an array of int
|
Output: |
Returns TRUE or False
|
Sample input: |
4
1
5
-5
1
|
Sample output: |
True
|
It's a little complicated, but I'll give you a way to experiment.
1: The entire array is first evaluated, if it is not an even number, it is returned directly to false, if it is the average, int tmpavege
2: To find all the numbers divisible by 5, to form a new array a5[], if it cannot be divisible by 5 but can be divisible by 3 to form a new array a3[ ], the remainder of the number, a[], adds the number of a5[] arrays, returns false if it is greater than the average Tmpavege, adds the number of a3[arrays, and returns false directly if it is greater than the average tmpavege;
3: With Tmpavege minus the a5[] array and getting int a5temp, the numbers in the a[array are grouped together, true if the sum can appear a5temp, or False if it returns.
You should be able to do this three-step implementation.
Feeling this problem is like packing problem.
1, to determine whether a multiple of 2, is not the case, directly return false. The results are SUM/2 into TMP
2, 5 multiples, 3 multiples in two arrays, two arrays and SUM5 sum3 respectively, then compared to TMP, if one of them is greater than TMP, returns false, if equal, returns True, is less than the next step.
3, packing problem. A separate Mount tmp-sum3 returns True if it can be loaded, otherwise false ...