首页 > XOR-pyramid
头像 sunsetcolors
发表于 2020-08-24 18:19:56
XOR-pyramid 题目地址: https://ac.nowcoder.com/acm/problem/112798 基本思路: 肯定不能暴力求所有,所以我们要找到它的递推关系,我们带入几个数字将化开: 也就是所以我们设,为这段区间的结果,我们能够得到,然后我们是每次是要找到里结果最大 展开全文
头像 luo想要个气球
发表于 2020-08-27 14:16:19
题意: 思路: #include <cstdio> #include <algorithm> using namespace std; const int N = 5e3 + 10; int n,f[N][N],mx[N][N]; int main(){ scan 展开全文
头像 issue是云哥的小迷×呀
发表于 2020-08-24 23:00:30
#include <bits/stdc++.h> using namespace std; const int maxn=5009; int a[maxn],n,dp[maxn][maxn],f[maxn][maxn]; int main() { cin >> n; 展开全文
头像 sunrise__sunrise
发表于 2020-08-24 23:25:08
题目描述 给出n个数,n<5000第二行给出n个数的权值分别是多少,给出f函数的定义,是依次相邻的异或,直到最终函数参数只有一个,得到的值就是参数的值。下面给出q次询问,每次询问给出l,r,问在这个区间中最大的f是什么? Solution 异或可以抵消,所以枚举起来不是很复杂,我枚举了长度为3 展开全文
头像 程序蒟蒻
发表于 2020-08-29 12:08:05
可以发现,f([l,r])迭代到倒数第二层,会变成f(f([l,r−1]),f([l+1,r]))=f([l,r−1])⊕f([l+1,r]) #include<iostream> #include<string> #include<math.h> #includ 展开全文
头像 blowhail
发表于 2020-08-29 12:44:46
推导一下f的式子所以用dp[l][r]来表示区间l,r的答案就可以得到 dp[l][r]=dp[l][r-1] dp[l+1][r] #include <cstdio> #include <iostream> #include <algorithm> #incl 展开全文

等你来战

查看全部