• [BZOJ2844]albus就是要第一个出场


    嘟嘟嘟(洛谷)


    这道题算是利用了线性基的一个性质:对于大小为(k)的线性基中亦或出来的一个数(x),那么用原数组的数亦或出来的所有数中,(x)出现了(2 ^ {n - k})次。
    那么就可以算出线性基中比(x)小的数有多少个(记为(cnt)),然后答案就是(cnt * 2 ^ {n - k} + 1)
    (其实我现在还不是特别懂)

    #include<cstdio>
    #include<iostream>
    #include<cmath>
    #include<algorithm>
    #include<cstring>
    #include<cstdlib>
    #include<cctype>
    #include<vector>
    #include<stack>
    #include<queue>
    using namespace std;
    #define enter puts("") 
    #define space putchar(' ')
    #define Mem(a, x) memset(a, x, sizeof(a))
    #define In inline
    typedef long long ll;
    typedef double db;
    const int INF = 0x3f3f3f3f;
    const db eps = 1e-8;
    const int maxn = 1e5 + 5;
    const int maxN = 31;
    const ll mod = 10086;
    inline ll read()
    {
    	ll ans = 0;
    	char ch = getchar(), last = ' ';
    	while(!isdigit(ch)) {last = ch; ch = getchar();}
    	while(isdigit(ch)) {ans = (ans << 1) + (ans << 3) + ch - '0'; ch = getchar();}
    	if(last == '-') ans = -ans;
    	return ans;
    }
    inline void write(ll x)
    {
    	if(x < 0) x = -x, putchar('-');
    	if(x >= 10) write(x / 10);
    	putchar(x % 10 + '0');
    }
    
    int n;
    int p[maxN];
    In void insert(int x)
    {
    	for(int i = maxN; i >= 0; --i)	if((x >> i) & 1)
    	{
    		if(p[i]) x ^= p[i];
    		else {p[i] = x; return;}
    	}
    }
    int b[maxN], cnt = 0;
    
    In ll quickpow(ll a, ll b)
    {
    	ll ret = 1;
    	for(; b; b >>= 1, a = a * a % mod)
    		if(b & 1) ret = ret * a % mod;
    	return ret;
    }
    
    int main()
    {
    	n = read(); ll x;
    	for(int i = 1; i <= n; ++i) x = read(), insert(x);
    	for(int i = 0; i <= maxN; ++i) if(p[i]) b[cnt++] = i;
    	x = read();
    	ll ans = 0;
    	for(int i = 0; i < cnt; ++i) if((x >> b[i]) & 1) ans += (1 << i);
    	ans %= mod;	
    	write((ans * quickpow(2, n - cnt) + 1) % mod), enter;
    	return 0;
    }
    
  • 相关阅读:
    喜马拉雅第三方客户端开发(接口和接口数据解析)。
    jquery-easyui中datagrid扩展,隐藏显示表头功能
    backbone ,jQuery-easyui,knockoutjs的整合使用
    WPF中的瀑布流布局(TilePanel)控件
    使用this.$refs['formName'].resetFields()无法重置表单
    js获取json对象的key值
    Hash表算法详解
    Redis入门
    ASP.Net 下载大文件的实现
    后端生成二维码
  • 原文地址:https://www.cnblogs.com/mrclr/p/10255359.html
Copyright © 2020-2023  润新知