Codeforces Round #648 (Div. 2) E - Maximum Subsequence Value 思维

自己动手模拟一下就好,最多三个数

#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
int read()
{
    int res=0,ch,flag=0;
    if((ch=getchar())=='-')             //判断正负
        flag=1;
    else if(ch>='0'&&ch<='9')           //得到完整的数
        res=ch-'0';
    while((ch=getchar())>='0'&&ch<='9')
        res=res*10+ch-'0';
    return flag?-res:res;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
const int N=1e6+10;
#define int long long
int a[N];
signed main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    ll ans=0;
    for(int i=1; i<=n; i++)
        for(int j=i; j<=n; j++)
            for(int k=j; k<=n; k++)
                ans=max(ans,(ll)(a[i]|a[j]|a[k]));
    cout<<ans<<endl;
    return 0;
}

 

上一篇:Cocos Creator Rect width exceeds maximum margin报错


下一篇:打印二叉树