【每日一题】XOR-pyramid
XOR-pyramid
https://ac.nowcoder.com/acm/problem/112798
题意:
思路:
#include <cstdio> #include <algorithm> using namespace std; const int N = 5e3 + 10; int n,f[N][N],mx[N][N]; int main(){ scanf("%d",&n); for(int i = 1;i <= n;i++){ scanf("%d",&f[i][i]); mx[i][i] = f[i][i]; } for(int len = 2;len <= n;len++){ for(int i = 1,j;i + len - 1 <= n;i++){ j = i + len - 1; mx[i][j] = f[i][j] = f[i][j - 1] ^ f[i + 1][j]; mx[i][j] = max(mx[i][j],max(mx[i][j - 1],mx[i + 1][j])); } } int q;scanf("%d",&q); while(q--){ int l,r;scanf("%d%d",&l,&r); printf("%d\n",mx[l][r]); } return 0; }
每日一题 文章被收录于专栏
每题一题题目