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 point strings, loops, functions, pointers, enumerations, bitwise operations, structures, associations, file operations, recursion
Run time limit 10M
Memory Limit 128
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
#include <iostream> #include <vector> #include <algorithm> #include <string> using namespace std
; BOOL Sum_same (int sum1, int sum2, int i, vector<int> &v) {for (int j = 0; J <= i; j +) {sum1 = V
[j];
for (int j = i + 1; j < V.size (); j + +) Sum2 + = V[j];
if (sum1 = = sum2) return true;
else return false;
int main () {vector<int> v,v3,v5;
int n;
CIN >> N;
int t;
for (int i = 0; i < n; i++) {cin >>t;
if (t% 5 = 0) {v5.push_back (t);
else if (t% 3 = 0) {v3.push_back (t);
} else{v.push_back (t);
} int sum1=0;
int sum2 = 0;
for (int i = 0; i < v5.size (); i++) sum1 + = V5[i];
for (int i = 0; i < v3.size (); i++) sum2 + = V3[i];
Sort (V.begin (), V.end ());
int flag = FALSE; do{for (int i = 0; i < v.size (); i++) {if (Sum_same (sum1, sum2, I, v)) {cout << "true" << Endl;
return 0;
}} while (Next_permutation (V.begin (), V.end ()));
cout << "false" << Endl;
return 0;
}