#include<iostream> #include<algorithm> #include<vector> #include<numeric> using namespace std; int main() { int n, m; while (cin>>n){ int error = 1; int sum3 = 0,sum5 = 0,sumoth=0; vector<int> v; for (int i = 0; i < n; i++){ cin >> m; if (m % 5 == 0) sum5 += m; else if (m % 3 == 0) sum3 += m; else{ v.push_back(m); sumoth += m; } } /*判断有没有解,和为奇数则没有解*/ if ((sum3 + sum5 + sumoth) % 2 != 0) goto False; do{ for (int i = 0;i < v.size(); i++){ /*全排列不是5和3的倍数的数,分组求和,利用数学x3+a=y5+b转为|x3-x5|=|a-b|来判断是否存在解*/ if (abs(accumulate(v.begin(), v.begin() + i, 0) - accumulate(v.begin() + i, v.end(), 0)) == abs(sum3 - sum5)){ error = 0; goto True; }; } } while (next_permutation(v.begin(), v.end())); False: if(error==1) cout << "false" << endl; True: if(error==0) cout << "true" << endl; } }