Topic Portal
Test instructions: Mushroom picking. Now picked up N Mountain, a total of 5 mountains, the final demand for three baskets of mushroom quantity is 1024 of the integer times, lost after the loss of 1024 until not more than 1024
Analysis: N <= 3 o'clock direct 1024, otherwise the pressure enumeration which three baskets are discarded, update the maximum
/************************************************* author:running_time* Created time:2015/10/28 Wednesday 19:21:49* Fi Le name:c.cpp ************************************************/#include <cstdio> #include <algorithm># Include <iostream> #include <sstream> #include <cstring> #include <cmath> #include <string > #include <vector> #include <queue> #include <deque> #include <stack> #include <list># Include <map> #include <set> #include <bitset> #include <cstdlib> #include <ctime>using namespace std; #define Lson L, Mid, RT << 1#define Rson mid + 1, R, RT << 1 | 1typedef long ll;const int N = 1e5 + 10;const int INF = 0x3f3f3f3f;const int MOD = 1e9 + 7;const Double EPS = 1e-10;c Onst Double PI = ACOs ( -1.0); int main (void) {int n; int a[5]; while (scanf ("%d", &n) = = 1) {memset (A,-1, sizeof (a)); int ans = 0; for (int i=0; i<n; ++i) scanf ("%d", &a[i]); if (n <= 3) {ans = 1024; } else {int S = 1 << 5; for (int i=0; i<s; ++i) {int num = __builtin_popcount (i); if (num! = 3) Continue; int x = 0, y = 0, sum = 0, sum2 = 0; for (int j=0; j<5; ++j) {if (I & (1 << j)) {if (a[j] = = 1) x+ +; else sum + = a[j]; } else {if (a[j] = =-1) y++; else sum2 + = A[j]; }} if (!x && sum% 1024x768! = 0) Continue; if (y) ans = max (ans, 1024); else {ans = max (ans, (sum2-1)% 1024 + 1); }}} printf ("%d\n", ans); }//cout << "time Elapsed:" << 1.0 * Clock ()/Clocks_peR_sec << "s.\n"; return 0;}
State compression uvalive 6068 the Little Girl who picks mushrooms (12 Changchun C)