P1297 [国家集训队]单选错位(期望)
期望入门
我们考虑涂到第$i$道题时的情况
此时题$i$答案有$a[i]$种,我们可能涂$a[i+1]$种
分类讨论:
1.$a[i]>=a[i+1]$:
可能涂到答案的概率为$(a[i+1]/a[i])*(1/a[i+1])=1/a[i]$,贡献为1
没涂到的概率为$1-1/a[i]$,贡献为0
期望值:$1*(1/a[i])+0*(1-1/a[i])=1/a[i]$
2.$a[i]<a[i+1]$:
可能涂到答案的概率为$(a[i]/a[i+1])*(1/a[i])=1/a[i+1]$,贡献为1
没涂到的概率为$1-1/a[i+1]$,贡献为0
期望值:$1*(1/a[i+1])+0*(1-1/a[i+1])=1/a[i+1]$
总结一下,每次的期望值就是$1/max(a[i],a[i+1])$
最后把每次的期望值累加起来就好辣
#include<cstdio>
#define N 10000005
inline int Max(int a,int b){return a>b?a:b;}
int a[N],n,A,B,C; double f;
int main(){
scanf("%d%d%d%d%d",&n,&A,&B,&C,a+);
for (register int i=;i<=n;i++)
a[i] = ((long long)a[i-] * A + B) % ;
for (register int i=;i<=n;i++)
a[i] = a[i] % C + ;
for(register int i=;i<n;++i)
f+=/(double)Max(a[i],a[i+]);
f+=/(double)Max(a[n],a[]);
printf("%.3lf",f);
return ;
}
P1297 [国家集训队]单选错位(期望)的更多相关文章
- Luogu P1297 [国家集训队]单选错位
P1297 [国家集训队]单选错位 题目背景 原 <网线切割>请前往P1577 题目描述 gx和lc去参加noip初赛,其中有一种题型叫单项选择题,顾名思义,只有一个选项是正确答案.试卷上 ...
- 洛谷P1297 [国家集训队]单选错位_数学期望
考虑第 iii 位, 那么当前共有 a[i]a[i]a[i] 种选项,那么当前选项正确的情况就是下一个被误填的答案与当前答案相同.换句话说,当前答案一共有 a[i]a[i]a[i] 种可能,而下一个答 ...
- Luogu P1297 [国家集训队]单选错位 | 概率与期望
题目链接 题解: 单独考虑每一道题目对答案的贡献. 设$g_i$表示gx在第$i$道题目的答案是否正确(1表示正确,0表示不正确),则$P(g_i=1)$表示gx在第$i$道题目的答案正确的概率. 我 ...
- P1297 [国家集训队]单选错位
题目背景 原 <网线切割>请前往P1577 题目描述 gx和lc去参加noip初赛,其中有一种题型叫单项选择题,顾名思义,只有一个选项是正确答案.试卷上共有n道单选题,第i道单选题有ai个 ...
- BZOJ2134 luoguP1297 [国家集训队]单选错位
单选错位 [问题描述] gx和lc去参加noip初赛,其中有一种题型叫单项选择题,顾名思义,只有一个选项是正确答案.试卷上共有n道单选题,第i道单选题有ai个选项,这ai个选项编号是1,2,3,…,a ...
- BZOJ.2134.[国家集训队]单选错位(概率 递推)
题目链接 如题目中的公式,我们只要把做对每个题的概率加起来就可以了(乘个1就是期望). 做对第i道题的概率 \[P_i=\frac{1}{max(a_{i-1},a_i)}\] 原式是 \(P_i=\ ...
- BZOJ_2134_单选错位——期望DP
BZOJ_2134_单选错位——期望DP 题意: 分析:设A为Ai ∈ [1,ai+1] 的概率,B为Ai = A(imodn+1)的概率显然P(A|B) = 1,那么根据贝叶斯定理P(B) = P( ...
- Bzoj 2134: [国家集训队2011]单选错位(期望)
2134: 单选错位 Time Limit: 10 Sec Memory Limit: 259 MB Description Input n很大,为了避免读入耗时太多,输入文件只有5个整数参数n, A ...
- BZOJ 2134: 单选错位( 期望 )
第i个填到第i+1个的期望得分显然是1/max(a[i],a[i+1]).根据期望的线性性, 我们只需将每个选项的期望值累加即可. ---------------------------------- ...
随机推荐
- 【UML】-NO.42.EBook.5.UML.1.002-【UML 大战需求分析】- 活动图 (Activity Diagram)
1.0.0 Summary Tittle:[UML]-NO.42.EBook.1.UML.1.002-[UML 大战需求分析]- 活动图 Style:DesignPattern Series:Desi ...
- 【Java】-NO.16.EBook.4.Java.1.012-【疯狂Java讲义第3版 李刚】- JDBC
1.0.0 Summary Tittle:[Java]-NO.16.EBook.4.Java.1.012-[疯狂Java讲义第3版 李刚]- JDBC Style:EBook Series:Java ...
- 拖拽控件java版
Button vv = new Button("vvvv"); DragSource.getDefaultDragSource().createDefaultDragGestur ...
- [LeetCode] 105. Construct Binary Tree from Preorder and Inorder Traversal_Medium tag: Tree Traversal
Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that ...
- [LeetCode] 74. Search a 2D Matrix_Medium tag: Binary Search
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the follo ...
- [LeetCode] 607. Sales Person_Easy tag: SQL
Description Given three tables: salesperson, company, orders.Output all the names in the table sales ...
- Python基础(三)Mysql数据库安装及使用
在python下使用mysql需要: 1.安装mysql 2.安装python pymysql包(pymysql包支持py3 跟mysqldb用法差不多) 一.安装mysql mysql下载地址:h ...
- Unable to update the EntitySet 'T_JsAPI' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.
前几天使用EF6的Db First模式改造了支付中心的数据访问层,废弃了ado.net. 同时,使用T4把实体类生成到了model层的PO目录下. 今天在db里新建了一张表,在edmx文件里更新模型( ...
- InstallShield2015制作安装包----------卸载前结束执行中的进程
方法一:InstallShiel直接调用cmd命令来杀掉进程. //更新或卸载时先关闭应用程序 sCmdLine=" /c taskkill /f /im \"Frs.exe\&q ...
- SpringMVC.入门篇.一.HelloWorld
SpringMVC.入门篇<一>HelloWorld 项目包结构如下: HelloController.java 代码 package com.charles.controller; im ...