bzoj 2844: albus就是要第一个出场
(一眼看上去线性基的大水题啊,写完线性基,然后处理了一下,尽量是的每个线性基的最高位且只有最高位是1,然后我就开心的开始算m是第几了,,,呵呵呵)
本题的正确姿势,,,在我开心之后,再乘以一个2^(n-tot),(tot是不为0线性基个数),,,
线性基只能构造出2^tot,然而集合子集有2^n个,,(所以就乘个2^(n-tot),,,,(大雾)),为什么相等也不知道,可能神犇都能yy出吧,反正本蒟蒻yy一下感觉没道理。
(数学这么优美的东西,肯定要一样多的,(大雾))
(哦,对了,这里的线性基可以高斯消元求,也可以直接那么抑或构造,然后在用线性基互相抑或一下只留最高位1)
1 /*#include<bits/stdc++.h> 2 #define N 100005 3 #define LL long long 4 #define inf 0x3f3f3f3f 5 using namespace std; 6 inline int ra() 7 { 8 int x=0,f=1; char ch=getchar(); 9 while (ch<'0' || ch>'9') {if (ch=='-') f=-1; ch=getchar();} 10 while (ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();} 11 return x*f; 12 } 13 int ksm(int a, int b) 14 { 15 int sum=1; 16 for(;b;b>>=1,a=a*a%10086) 17 if (b&1) sum=sum*a%10086; 18 return sum%10086; 19 } 20 int k,cnt,m,a[N],p[105]; 21 int b[N]; 22 void guass() 23 { 24 k=cnt; 25 for (int i=1; i<=cnt; i++){ 26 for (int j=i+1; j<=cnt; j++) 27 if (a[j]>a[i]) 28 swap(a[i],a[j]); 29 if (!a[i]) { 30 k=i-1; 31 break; 32 } 33 for (int j=31; ~j; j--) 34 if ((a[i]>>j)&1){ 35 b[i]=j; 36 for (int k=1; k<=cnt; k++) 37 if (k!=i && (a[k]>>j)&1) 38 a[k]^=a[i]; 39 break; 40 } 41 } 42 } 43 int main() 44 { 45 cnt=ra(); 46 for (int i=1; i<=cnt; i++) a[i]=ra(); 47 m=ra(); 48 if (m==0){cout<<"1";return 0;} 49 guass(); 50 int ans=1; 51 for (int i=1; i<=k; i++) 52 if ((m>>b[i])&1) 53 { 54 m^=a[i]; 55 ans=(ans+ksm(2,cnt-i))%10086; 56 } 57 cout<<ans; 58 return 0; 59 } */ 60 #include<bits/stdc++.h> 61 #define N 100005 62 #define LL long long 63 #define inf 0x3f3f3f3f 64 using namespace std; 65 inline LL ra() 66 { 67 LL x=0,f=1; char ch=getchar(); 68 while (ch<'0' || ch>'9') {if (ch=='-') f=-1; ch=getchar();} 69 while (ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();} 70 return x*f; 71 } 72 int ksm(int a, int b) 73 { 74 int sum=1; 75 for(;b;b>>=1,a=a*a%10086) 76 if (b&1) sum=sum*a%10086; 77 return sum%10086; 78 } 79 int n,m,a[N],p[105],b[105],tot; 80 bool flag; 81 int main() 82 { 83 n=ra(); 84 for (int i=1; i<=n; i++) a[i]=ra(); 85 m=ra(); 86 if (m==0){cout<<"1";return 0;} 87 for (int i=1; i<=n; i++) 88 for (int j=30; ~j; j--) 89 if ((1<<j)&a[i]) 90 { 91 if (!p[j]) 92 { 93 p[j]=a[i]; 94 break; 95 } 96 a[i]^=p[j]; 97 if (!a[i]) flag=1; 98 } 99 int cnt=0; 100 for (int i=30; ~i; i--) 101 { 102 if (!p[i]) {continue;} 103 for (int j=i-1; ~j; j--) 104 if (p[i]&(1<<j)) 105 p[i]^=p[j]; 106 } 107 for (int i=0; i<=30; i++) 108 if (p[i]) b[++tot]=i; 109 int ans=0; 110 for (int i=1; i<=tot; i++) 111 if ((m>>b[i])&1) 112 { 113 m^=p[i-1]; 114 ans+=(1<<(i-1))%10086; 115 ans%=10086; 116 } 117 cout<<1+(ans*ksm(2,n-tot))%10086; 118 return 0; 119 }
转载于:https://www.cnblogs.com/ccd2333/p/6435384.html
bzoj 2844: albus就是要第一个出场相关推荐
- [BZOJ 2844] albus就是要第一个出场
2844: albus就是要第一个出场 Time Limit: 6 Sec Memory Limit: 128 MB Submit: 2316 Solved: 964 [Submit][Statu ...
- bzoj 2844 albus就是要第一个出场
2844: albus就是要第一个出场 Time Limit: 6 Sec Memory Limit: 128 MB Submit: 1402 Solved: 593 [Submit][Statu ...
- bzoj 2844: albus就是要第一个出场(线性基)
2844: albus就是要第一个出场 Time Limit: 6 Sec Memory Limit: 128 MB Submit: 1635 Solved: 680 [Submit][Statu ...
- bzoj 2844: albus就是要第一个出场 高斯消元
LINK 题意:看题目不如看样例解释.给出有n个数的集合,对这些子集中的数求异或,升序统计所有子集得到的数(重复会被计入),询问一个数x,问这个数出现的第一个位置 思路:在这里要求一个所有可能出现的异 ...
- [BZOJ 2844]albus就是要第一个出场
Description 已知一个长度为n的正整数序列A(下标从1开始), 令 S = { x | 1 <= x <= n }, S 的幂集2S定义为S 所有子 集构成的集合.定义映射 f ...
- BZOJ 2844 albus就是要第一个出场(线性基)
Description 已知一个长度为n的正整数序列A(下标从1开始), 令 S = { x | 1 <= x <= n }, S 的幂集2^S定义为S 所有子 集构成的集合.定义映射 f ...
- 2844: albus就是要第一个出场
2844: albus就是要第一个出场 链接 分析: 和HDU3949差不多互逆,这里需要加上相同的数. 结论:所有数任意异或,构成的数出现一样的次数,次数为$2^{n-cnt}$,cnt为线性基的大 ...
- 【BZOJ 2844】 albus就是要第一个出场
2844: albus就是要第一个出场 Time Limit: 6 Sec Memory Limit: 128 MB Submit: 436 Solved: 190 [Submit][Status ...
- 【bzoj 2844】: albus就是要第一个出场
http://www.lydsy.com/JudgeOnline/problem.php?id=2844 先求线性基,那么可以得到0的个数cnt0 每个数与0异或都会得到2^cnt0这个数.... 那 ...
- BZOJ2844:albus就是要第一个出场——题解
https://www.lydsy.com/JudgeOnline/problem.php?id=2844 已知一个长度为n的正整数序列A(下标从1开始), 令 S = { x | 1 <= x ...
最新文章
- kmeans及模型评估指标_模型评估常用指标
- this. $ refs: undefined 的解决办法
- vue 组件id重复问题
- linux进程假死的原因_一次Spring Boot假死诊断
- 什么才是好代码、高质量代码?
- linux系统vsftpd登陆慢卡怎么办
- 关于求职简历的碎碎念。
- tomcat闪退解决方案
- 替换Jar包中的一个文件 Replace a file in a JAR
- java ftp模糊查询_前端js模糊搜索(模糊查询)
- .net core 多平台开发体验
- 每日算法系列【LeetCode 992】K个不同整数的子数组
- 图像旋转(任意角度)matlab
- python定时任务_Python定时任务(下)
- adobe怎么统计字数_pdf文件怎么快速统计字数?
- OceanBase部署observer启动后log日志狂写问题
- python01g内存读取10g文件并排序_将大文件逐行读取到Python2.7中时的内存使用
- git第一次提交代码至远程仓库
- 云服务器云虚拟主机区别,带你了解云服务器和云虚拟主机有什么区别?
- LDK3读书笔记(第三章:进程管理)
热门文章
- 湘潭比赛有感---铩羽之行
- python的整数类型_Python 标准数据类型:Bytes
- MATLAB--卡尔曼滤波
- python中fac函数_python系列-基础
- OpenCV对图片的读写,像素值的访问,修改
- Swift 5 用TableView实现动态Excel表格Spreadsheet
- 翻译:swift 5通过使用泛型进行高级异步操作Operation
- 半小时在白板上写代码实现一致性哈希Hash算法
- 易筋SpringBoot 2.2 | 第三十二篇:Redis Docker入门
- 2021-09-14基于用 户 行为 序列建模的推荐算法研究