P4869 albus就是要第一个出场
Posted LORDXX
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了P4869 albus就是要第一个出场相关的知识,希望对你有一定的参考价值。
#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就是要第一个出场的主要内容,如果未能解决你的问题,请参考以下文章