Run ID Author Problem Lang Verdict Score Time Memory Code Length Submit Time
55159 raoyueyang 线性基 (basis) C++ Runtime Error 0 26 MS 316 KB 1066 2022-08-09 11:41:04

Tests(0/10):


#include<bits/stdc++.h> #define int long long using namespace std; inline int read() { int x=0; char c=getchar(); for(; c<'0' || c>'9'; c=getchar()); for(; c<='9' && c>='0'; c=getchar()) x=(x<<3)+(x<<1)+c-'0'; return x; } int a[10000]; int total = 0; int x,y; main() { int n; n = read(); for(int i=1; i<=n; i++) { a[i] = read(); total += a[i]*a[i]; } // cout << total << endl; if(n == 1) { cout << a[1]*a[1] << endl; return 0; } if(n == 2) { cout << (a[1] & a[2])*(a[1] & a[2]) + (a[1] | a[2]) * (a[1] | a[2]) << endl; return 0; } for(int i=1; i<=n; i++) { for(int j=1; j<=i; j++) { x = a[i] & a[j]; y = a[i] | a[j]; if(total-a[i]*a[i]-a[j]*a[j]+x*x+y*y > total) { total = total-a[i]*a[i]-a[j]*a[j]+x*x+y*y; // cout << total << endl; // cout << "i and j = " << i << " " << j << endl; // cout << x << " " << y << endl; } } } cout << total << endl; return 0; }


Judgement Protocol: