Solution -「LOCAL」舟游
\(\mathcal{Description}\)
\(n\) 中卡牌,每种三张。对于一次 \(m\) 连抽,前 \(m-1\) 次抽到第 \(i\) 种的概率是 \(p_i\),第 \(m\) 次抽到第 \(i\) 种的概率是 \(q_i\)。若抽到第 \(i\) 种,会等概率地得到三张卡牌中的一张。求得到所有 \(3n\) 张卡的期望 \(m\) 连抽次数。对 \(2000000011\) 取模。
\(n\le6\),\(m\le64\)。
\(\mathcal{Solution}\)
目睹 Tiw 踩标算,%%%
\(\mathcal{Case~1}\)
长得就像状压期望 DP。令 \(f(S,i)\) 表示抽到的卡牌集合为 \(S\)(同种卡牌显然无序,用两个 bit 记录一种卡牌拥有的张数即可)。发现转移会有一个 \(f(S,1)\leftarrow f(S,2)\leftarrow\cdots\leftarrow f(S,m)\leftarrow f(S,1)\) 的大小为 \(m\) 的简单环。手动消元解出来就好。
考 场 上 写 自 闭 了。
\(\mathcal{Case~2}\)
长得就像 \(\text{Min-Max}\) 反演——Tiw。\(\text{Min-Max}\) 反演在期望意义下的式子长成:
\]
其中 \(S\) 是随机变量集合。对于本题,我们相当于要求每张卡被抽到时间的最大值的期望,可以用上式反演成求每张卡被抽到时间的最小值的期望。为方便推式子,令 \(p\) 和 \(q\) 的意义为抽到某一张卡的概率。对于某个具体的卡牌集合,就要求至少抽中 \(T\) 中一张卡牌的期望时间。那么:
\]
枚举集合 \(T\),就做完了。(
复杂度 \(\mathcal O(4^n\log 2000000011)\)。
\(\mathcal{Code}\)
Case 2.
/* Clearink */
#include <cstdio>
typedef long long LL;
const int MAXN = 9, MAXM = 64, MAXS = 1 << 18, MOD = 2000000011;
int n, m, ans, p[MAXN + 5], q[MAXN + 5];
inline int add ( LL a, const int b ) { return ( a += b ) < MOD ? a : a - MOD; }
inline int sub ( LL a, const int b ) { return ( a -= b ) < 0 ? a + MOD : a; }
inline int mul ( LL a, const int b ) { return ( a *= b ) < MOD ? a : a % MOD; }
inline int qkpow ( int a, int b ) {
int ret = 1;
for ( ; b; a = mul ( a, a ), b >>= 1 ) ret = mul ( ret, b & 1 ? a : 1 );
return ret;
}
inline void solve ( const int id, const bool s, const int sump, const int sumq, const int ways ) {
if ( id == n + 1 ) {
int val = mul ( ways, qkpow (
sub ( 1, mul ( qkpow ( sub ( 1, sump ), m - 1 ), sub ( 1, sumq ) ) ), MOD - 2 ) );
ans = ( s ? add : sub )( ans, val );
return ;
}
solve ( id + 1, s, sump, sumq, ways );
solve ( id + 1, !s, add ( sump, p[id] ), add ( sumq, q[id] ), mul ( ways, 3 ) );
solve ( id + 1, s, add ( sump, mul ( p[id], 2 ) ), add ( sumq, mul ( q[id], 2 ) ), mul ( ways, 3 ) );
solve ( id + 1, !s, add ( sump, mul ( p[id], 3 ) ), add ( sumq, mul ( q[id], 3 ) ), ways );
}
int main () {
freopen ( "arknights.in", "r", stdin );
freopen ( "arknights.out", "w", stdout );
scanf ( "%d %d", &n, &m );
int rv = qkpow ( 300 * n, MOD - 2 );
for ( int i = 1; i <= n; ++ i ) scanf ( "%d", &p[i] ), p[i] = mul ( p[i], rv );
for ( int i = 1; i <= n; ++ i ) scanf ( "%d", &q[i] ), q[i] = mul ( q[i], rv );
solve ( 1, 0, 0, 0, 1 );
printf ( "%d\n", ans );
return 0;
}
Solution -「LOCAL」舟游的更多相关文章
- Solution -「LOCAL」二进制的世界
\(\mathcal{Description}\) OurOJ. 给定序列 \(\{a_n\}\) 和一个二元运算 \(\operatorname{op}\in\{\operatorname{ ...
- Solution -「LOCAL」大括号树
\(\mathcal{Description}\) OurTeam & OurOJ. 给定一棵 \(n\) 个顶点的树,每个顶点标有字符 ( 或 ).将从 \(u\) 到 \(v\) ...
- Solution -「LOCAL」过河
\(\mathcal{Description}\) 一段坐标轴 \([0,L]\),从 \(0\) 出发,每次可以 \(+a\) 或 \(-b\),但不能越出 \([0,L]\).求可达的整点数. ...
- Solution -「LOCAL」Drainage System
\(\mathcal{Description}\) 合并果子,初始果子的权值在 \(1\sim n\) 之间,权值为 \(i\) 的有 \(a_i\) 个.每次可以挑 \(x\in[L,R]\) ...
- Solution -「LOCAL」Burning Flowers
灼之花好评,条条生日快乐(假装现在 8.15)! \(\mathcal{Description}\) 给定一棵以 \(1\) 为根的树,第 \(i\) 个结点有颜色 \(c_i\) 和光亮值 ...
- Solution -「LOCAL」画画图
\(\mathcal{Description}\) OurTeam. 给定一棵 \(n\) 个点的树形随机的带边权树,求所有含奇数条边的路径中位数之和.树形生成方式为随机取不连通两点连边直到全 ...
- Solution -「LOCAL」ZB 平衡树
\(\mathcal{Description}\) OurOJ. 维护一列二元组 \((a,b)\),给定初始 \(n\) 个元素,接下来 \(m\) 次操作: 在某个位置插入一个二元组: 翻 ...
- Solution -「LOCAL」充电
\(\mathcal{Description}\) 给定 \(n,m,p\),求序列 \(\{a_n\}\) 的数量,满足 \((\forall i\in[1,n])(a_i\in[1,m])\l ...
- Solution -「LOCAL」「cov. 牛客多校 2020 第五场 C」Easy
\(\mathcal{Description}\) Link.(完全一致) 给定 \(n,m,k\),对于两个长度为 \(k\) 的满足 \(\left(\sum_{i=0}^ka_i=n\r ...
随机推荐
- gitlab新增ssh
https://blog.csdn.net/u011925641/article/details/79897517
- Git 基础指令
Git 基础指令 Git 基础指令 获取 Git 仓库 在已存在目录中初始化仓库 克隆现有的仓库 记录仓库与仓库的更新 仓库的记录 检查当前文件状态 三部曲 跟踪新文件 提交更新 移除文件 推送到远程 ...
- HDOJ3579Hello Kiki
https://acm.hdu.edu.cn/showproblem.php?pid=3579 一些坑点.首先是如果说最后求得到的结果为0,那么在数学意义上这是正确的,0对于任何的确是最小的整数解,但 ...
- leetcode 1288. 删除被覆盖区间
问题描述 给你一个区间列表,请你删除列表中被其他区间所覆盖的区间. 只有当 c <= a 且 b <= d 时,我们才认为区间 [a,b) 被区间 [c,d) 覆盖. 在完成所有删除操作后 ...
- 微服务架构 | *3.5 Nacos 服务注册与发现的源码分析
目录 前言 1. 客户端注册进 Nacos 注册中心(客户端视角) 1.1 Spring Cloud 提供的规范标准 1.2 Nacos 的自动配置类 1.3 监听服务初始化事件 AbstractAu ...
- sql语句 异常 Err] 1064 - You have an error in your SQL syntax;
在我们开发的工程中,有时候会报[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds ...
- 【记录一个问题】thanos receiver在更换tsdb文件后,内存并未显著下降
在16:14,切换了TSDB 在16::15分切换了TSDB,并且上游未写入数据 容器的内存并未在这个时刻明显下降 疑惑: 如果thanos receiver的内存占用不与time series数量正 ...
- LaTex用法笔记(一)——LaTex源文件的基本结构
首先打开TeXstudio,创建一个新文件并保存 用\documentclass{article}引入一个文档类,也可以引用book/report/letter 然后用\begin{}和\end{}输 ...
- Spring Boot Starter 和 ABP Module
Spring Boot 和 ABP 都是模块化的系统,分别是Java 和.NET 可以对比的框架.模块系统是就像乐高玩具一样,一块一块零散积木堆积起一个精彩的世界.每种积木的形状各不相同,功能各不相同 ...
- 记一次redis 基于spring实现类对同一个KEY序列化内容不同导致一次事故
我们的场景是这样的 我们对一个key:比如list.point.card:1 @Resourceprivate RedisTemplate<String, Long> redisTempl ...