宿松 做网站,湖南省建设工程造价管理协会网站,wordpress博客文章怎么设置,做网络平台需要什么条件https://blog.csdn.net/noone0/article/details/78289517
目前没有题目链接。
题意:长度为n的序列a,选出两个元素,其或运算结果的最大值为多少,并求出a[i]|a[j]mx的方案数? n1e5,0a[i]2^17,m17. 假如最大值为mx,若x|ymx 则x和y肯定为mx的子集.否则或运算结果…https://blog.csdn.net/noone0/article/details/78289517
目前没有题目链接。
题意:长度为n的序列a,选出两个元素,其或运算结果的最大值为多少,并求出a[i]|a[j]mx的方案数? n1e5,0a[i]2^17,m17. 假如最大值为mx,若x|ymx 则x和y肯定为mx的子集.否则或运算结果肯定不为mx. 枚举最大值 在枚举mx的子集x. 则此时y要包含(mx-i)这个子集.(若y比mx多出某个为1的bit位 则后面最大值还会更新.)
求个数,则需要知道序列中有多少个元素有子集mask(mx-i).
F(mask) 序列中有多少个数存在一个子集为mask,暴力O(3^m)枚举水过..
#includecstdio
#includeiostream
#includealgorithm
#includequeue
#includemap
#includevector
#includeset
#includestring
#includecmath
#includecstring
#define F first
#define S second
#define ll long long
#define pb push_back
#define pm make_pair
using namespace std;
typedef pairint,int PII;
const int MAX 2e5 5;
int a[MAX],num[MAX];
int f[MAX],a[MAX];
int main()
{int n;cinn;for(int i 1; in; i) {scnf(%d,ai);num[a[i]];}int up 117;for(int sta 0; staup; sta) {for(int i sta; i; i sta(i-1)) {//枚举子集 f[i] num[sta];}f[0] num[sta];}ll ans 0;int maxx 0;for(int sta 0; staup; sta) {ll res 0;for(int i sta; i; i sta(i-1)) {res num[i] * f[sta-i];}res num[0] * f[sta];res - num[sta];if(res) {ans res/2;maxx sta;}}printf(%d %d\n,maxx,ans); return 0 ;
}