bzoj 4036 [HAOI2015]按位或——min-max容斥+FMT
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4036
题解:https://www.cnblogs.com/Zinn/p/10260126.html
#include<cstdio>
#include<cstring>
#include<algorithm>
#define db double
using namespace std;
const int N=,M=(<<)+;
int n,bin[N],lm,ct[M];
db ans,mn[M],p[M];bool vis[N];
void fmt(db *a)
{
for(int i=;i<lm;i<<=)
for(int s=;s<lm;s++)
if(s&i)p[s]+=p[s^i];
}
int main()
{
scanf("%d",&n);
bin[]=;for(int i=;i<=n;i++)bin[i]=bin[i-]<<; lm=bin[n];
for(int s=;s<lm;s++)
{
scanf("%lf",&p[s]); if(!p[s])continue;
for(int i=;i<n;i++)if(s&bin[i])vis[i]=;
}
for(int i=;i<n;i++)if(!vis[i]){puts("INF");return ;}
fmt(p);
for(int s=,u=lm-;s<lm;s++)mn[s]=/(-p[u^s]);//s=1//only p[u]=1 for legal
for(int s=;s<lm;s++)ct[s]=ct[s-(s&-s)]+;
for(int s=;s<lm;s++)//s=1
(ct[s]&)?ans+=mn[s]:ans-=mn[s];
printf("%.10f\n",ans);
return ;
}
bzoj 4036 [HAOI2015]按位或——min-max容斥+FMT的更多相关文章
- bzoj 4036: [HAOI2015]按位或【min-max容斥+FWT】
其实也不是FWT--我也不知道刷FWT专题问什么会刷出来这个东西 这是min-max容斥讲解:https://www.zybuluo.com/ysner/note/1248287 总之就是设min(s ...
- [BZOJ 4036][HAOI2015]按位或
4036: [HAOI2015]按位或 Time Limit: 10 Sec Memory Limit: 256 MBSec Special JudgeSubmit: 746 Solved: 4 ...
- BZOJ 4036: [HAOI2015]按位或 集合幂函数 莫比乌斯变换 莫比乌斯反演
http://www.lydsy.com/JudgeOnline/problem.php?id=4036 http://blog.csdn.net/lych_cys/article/details/5 ...
- [HAOI2015]按位或(min-max容斥,FWT,FMT)
题目链接:洛谷 题目大意:给定正整数 $n$.一开始有一个数字 $0$,然后每一秒,都有 $p_i$ 的概率获得 $i$ 这个数 $(0\le i< 2^n)$.一秒恰好会获得一个数.每获得一个 ...
- BZOJ4036 [HAOI2015]按位或 【minmax容斥 + 期望 + FWT】
题目链接 BZOJ4036 题解 好套路的题啊,,, 我们要求的,实际上是一个集合\(n\)个\(1\)中最晚出现的\(1\)的期望时间 显然\(minmax\)容斥 \[E(max\{S\}) = ...
- 【BZOJ4036】按位或(Min-Max容斥,FWT)
[BZOJ4036]按位或(Min-Max容斥,FWT) 题面 BZOJ 洛谷 题解 很明显直接套用\(min-max\)容斥. 设\(E(max\{S\})\)表示\(S\)中最晚出现元素出现时间的 ...
- bzoj 4036 按位或 —— min-max容斥+FMT
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4036 min-max容斥:https://blog.csdn.net/ez_2016gdgz ...
- BZOJ 4036 [HAOI2015] Set 解题报告
首先我们不能一位一位的考虑,为什么呢? 你想想,你如果一位一位地考虑的话,那么最后就只有 $n$ 个数字,然而他给了你 $2^n$ 个数字,怎么看都不对劲呀.(我是因为这样子弄没过样例才明白的) 所以 ...
- P3175-[HAOI2015]按位或【min-max容斥,FWT】
正题 题目链接:https://www.luogu.com.cn/problem/P3175 题目大意 开始有一个\(n\)位二进制数\(s=0\),每次有\(p_i\)概率选取数字\(i\)让\(s ...
随机推荐
- linux时区问题
时区问题很麻烦- 0.查看时间命令 #date 查看系统时间 #date -s 修改时间,看下面的例子 #// (将系统日期设定为2014年07月16日) #:: (将系统时间设定为下午11::) # ...
- Python3.x:os.path模块
Python3.x:os.path模块 #返回绝对路径 os.path.abspath(path) #返回文件名 os.path.basename(path) #返回list(多个路径)中,所有pat ...
- sqlite3 shell方向键、浏览历史命令不能用的问题
在sqlite3 shell下,按上下方向键可以浏览历史命令,按左右方向键则可以将光标移动到命令中任意字符位置,从而可以修改错误的语句或误敲的字符.所以方向键是sqlite3 shell下最常用的功能 ...
- MSBI
https://blog.csdn.net/fanyingnedu/article/details/78597207 Familiarity with Microsoft BI Stack - SSI ...
- [笔记] SQL性能优化 - 常用语句(二)
1.查询CPU开销大的语句 total_worker_time/execution_count AS avg_cpu_cost, plan_handle, execution_count, ( , ( ...
- 图像添加logo水印函数
<?php //图像添加水印函数 /** *为一张图片添加上一个logo水印(以保存新图片的方式实现) *@param string $picname 被缩放的处理图片源 *@param int ...
- c++ 容器排序
#include <algorithm> #include <functional> #include <array> #include <iostream& ...
- install ros-indigo-ecl-build
-- ==> add_subdirectory(bp_smart_charging/bp_dock_drive) CMake Warning at /opt/ros/indigo/share/c ...
- python 作用域,命名空间
def scope_test(): def do_local(): spam = "local spam" def do_nonlocal(): nonlocal spam spa ...
- HTMLElement.hidden; CSS Attr Selectors的用处; DOM的className方法; ::before和::after伪元素
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/hidden https://codepen.io/pen/ <elem ...