[Offer收割]编程练习赛12 register

Ended

Participants:1323

Verdict:Accepted
Score:100 / 100
Submitted:2017-04-02 13:42:31

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
const int N = 10000;
long long a[100000];
int n;
bool cmp(long long a, long long b){
    return a > b;
}
int main(){
    int test;
    scanf("%d",&test);
    while (test--){
        long long ans = 0;
        scanf("%d",&n);
        for (int i = 0; i < n; i++){
            scanf("%lld",a+i);
        }
        sort(a,a+n,cmp);
        for (int i = 0; i < min(N,n); i++){
            for (int j = i+1; j < min(N,n); j++){
                ans = max (ans,a[i] * a[j] * (a[i] & a[j]));
            }
        }
        printf("%lld\n",ans);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX