The modulo 20121014 is just a dumb... I can't use it... because the answer is up to 1024... a small amount of data... situation discussion ..
Program:
[Cpp]
# Include <iostream>
# Include <stdio. h>
# Include <string. h>
# Include <math. h>
# Include <algorithm>
# Include <stack>
# Include <queue>
# Include <set>
# Define ll long
Using namespace std;
Int n, a [10], ans, sum;
Int main ()
{
Int I, j, k, m;
While (scanf ("% d", & n )! = EOF)
{
Ans = sum = 0;
For (I = 1; I <= n; I ++)
{
Scanf ("% d", & a [I]);
Sum + = a [I];
}
If (n <4) ans = 1024;
Else
If (n = 4)
{
For (I = 1; I <= 4; I ++)
For (j = I + 1; j <= 4; j ++)
{
M = a [I] + a [j];
While (m> 1024) m-= 1024;
If (m> ans) ans = m;
}
For (I = 1; I <= 4; I ++)
For (j = I + 1; j <= 4; j ++)
For (k = j + 1; k <= 4; k ++)
If (a [I] + a [j] + a [k]) % 1024 = 0) ans = 1024;
} Else
{
For (I = 1; I <= 5; I ++)
For (j = I + 1; j <= 5; j ++)
For (k = j + 1; k <= 5; k ++)
If (a [I] + a [j] + a [k]) % 1024 = 0)
{
M = sum-a [I]-a [j]-a [k];
While (m> 1024) m-= 1024;
If (m> ans) ans = m;
}
}
Printf ("% d \ n", ans );
}
Return 0;
}