码迷,mamicode.com
首页 > 其他好文 > 详细

P4869 albus就是要第一个出场

时间:2020-07-07 17:18:53      阅读:40      评论:0      收藏:0      [点我收藏+]

标签:local   out   const   root   amp   query   ||   lang   gcc   

#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<bitset>
#include<map>
//#include<regex>
#include<cstdio>
#include <iomanip>
#pragma GCC optimize(2)
#define up(i,a,b)  for(int i=a;i<b;i++)
#define dw(i,a,b)  for(int i=a;i>b;i--)
#define upd(i,a,b) for(int i=a;i<=b;i++)
#define dwd(i,a,b) for(int i=a;i>=b;i--)
//#define local
typedef long long ll;
typedef unsigned long long ull;
const double esp = 1e-6;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int inf = 1e9;
using namespace std;
ll read()
{
	char ch = getchar(); ll x = 0, f = 1;
	while (ch<‘0‘ || ch>‘9‘) { if (ch == ‘-‘)f = -1; ch = getchar(); }
	while (ch >= ‘0‘ && ch <= ‘9‘) { x = x * 10 + ch - ‘0‘; ch = getchar(); }
	return x * f;
}
typedef pair<int, int> pir;
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lrt root<<1
#define rrt root<<1|1
const int N = 1e5 + 10;
const int mod = 10086;
ll quick_pow(ll a, ll b)
{
	ll res = 1;
	while (b)
	{
		if (b & 1)res = (res*a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return res;
}
struct xxj {
	ll b[100];
	int cnt = 0;
	void insert(ll x)
	{
		dwd(i, 60, 0)
		{
			if (x>>i&1)
			{
				if (b[i])
				{
					x ^= b[i];
				}
				else {
					cnt++;
					b[i] = x;
					upd(j, 0, i - 1)if (b[i] >> j & 1)b[i] ^= b[j];
					upd(j, i + 1, 60)if (b[j] >> i & 1)b[j] ^= b[i];
					break;
				}
			}
		}
	}
	ll query(ll k) {
		vector<int>vec;
		upd(i, 0, 60)if (b[i])vec.push_back(i);
		ll res = 0;
		up(i, 0, vec.size())
		{
			if (k >> vec[i] & 1)res |= (1 << i);
		}
		return res%mod;
	}
}X;
int n;
int main()
{
	n = read();
	ll u;
	upd(i, 1, n)
	{
		u = read();
		X.insert(u);
	}
	ll q = read();
	ll temp = X.query(q);
	ll ans = (quick_pow(2, n - X.cnt)*temp%mod + 1) % mod;
	cout << ans << endl;
	return 0;
}

P4869 albus就是要第一个出场

标签:local   out   const   root   amp   query   ||   lang   gcc   

原文地址:https://www.cnblogs.com/LORDXX/p/13261792.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!