Link: Ultraviolet A 1323-Vivian's Problem
Given the number of N, add a power EI for each number, and the result of the N base multiplication is M. If the sum of all the factors of M can be written as 2x, returns the maximum value of X. If no conditions are met, no is output.
Solution: If a number can be written as the product of several different Mason prime numbers, the factor and the number can be written as 2x.
232? The range of 1 has only eight prime Mason numbers, so it can be processed by the pressure.
The prime number of Mason is a prime number in the form of 2 ^ I-1.
/********************** Mason prime number, (2 ^ K) -1 ** if a number can be divided into the product of several different Mason prime numbers, all the factors of the number and can be written in the form of 2 ^ n. * *********************/# Include <cstdio> # include <cstring> # include <algorithm> using namespace STD; typedef long ll; const int maxp = 8; const int f [maxp + 5] = {2, 3, 5, 7, 13, 17, 19, 31 }; int N, ANS, s [105]; ll MPRI [maxp + 5]; void insert (ll u) {s [N] = 0; For (INT I = 0; I <maxp; I ++) {If (U % MPRI [I] = 0) {s [N] | = (1 <I ); u/= MPRI [I]; If (U % MPRI [I] = 0) return ;}} if (u = 1) n ++ ;} int solve (INT s) {int ret = 0; For (INT I = 0; I <maxp; I ++) if (S & (1 <I )) RET + = f [I]; return ret;} void DFS (INT D, int s) {ans = max (ANS, solve (s )); for (INT I = D; I <n; I ++) if (S & S [I]) = 0) DFS (I + 1, S | s [I]);} int main () {for (INT I = 0; I <maxp; I ++) MPRI [I] = (1ll <F [I])-1; ll N, A; while (scanf ("% LLD", & n) = 1) {n = 0; For (INT I = 0; I <n; I ++) {scanf ("% LLD", & A); insert ();} if (n = 0) printf ("NO \ n"); else {ans = 0; DFS (0, 0); printf ("% d \ n ", ans) ;}} return 0 ;}