bzoj 5094 [Lydsy1711月赛]硬盘检测 概率dp
[Lydsy1711月赛]硬盘检测
Time Limit: 1 Sec Memory Limit: 256 MB
Submit: 273 Solved: 75
[Submit][Status][Discuss]
Description
Input
第一行包含一个正整数m(m=10000),表示随机访问硬盘的次数。
Output
输出一行一个整数,即n的大小。
Sample Input
2743802941
2520732963
3408553159
1132588462
2520732963
1252627160
2963673642
3972869548
2743802941
684663103
2743802941
3972869548
2520732963
1252627160
1252627160
Sample Output
HINT
Source
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <cmath> using namespace std;
int m,tot,ans;
double mx,sum;
map<int,int> s;
int cnt[];
double jc[];
inline double c(int a,int b)
{
if(a<b) return -1e10;
return jc[a]-jc[a-b]-jc[b];
}
inline int rd()
{
int ret=,f=; char gc=getchar();
while(gc<''||gc>'') {if(gc=='-') f=-f; gc=getchar();}
while(gc>=''&&gc<='') ret=ret*+(gc^''),gc=getchar();
return ret*f;
}
int main()
{
m=rd();
register int n,i,a,tmp;
for(i=;i<=m;i++)
{
a=rd();
if(!s[a]) s[a]=++tot;
cnt[s[a]]++;
}
mx=-1e10;
for(i=;i<=m;i++) jc[i]=jc[i-]+log(i);
for(n=;n<=;n*=)
{
if(n<tot) continue;
sum=;
for(i=;i<=tot;i++) sum+=log(n-i+)-log(i);
sum+=-log(n)*m,tmp=m;
for(i=;i<=tot;i++) sum+=c(tmp,cnt[i]),tmp-=cnt[i];
if(sum>mx) mx=sum,ans=n;
}
printf("%d",ans);
}
bzoj 5094 [Lydsy1711月赛]硬盘检测 概率dp的更多相关文章
- 【BZOJ5094】硬盘检测 概率
[BZOJ5094]硬盘检测 Description 很久很久以前,小Q买了一个大小为n单元的硬盘,并往里随机写入了n个32位无符号整数.因为时间过去太久,硬盘上的容量字眼早已模糊不清,小Q也早已忘记 ...
- bzoj5091 [Lydsy1711月赛]摘苹果 概率题
[Lydsy1711月赛]摘苹果 Time Limit: 1 Sec Memory Limit: 256 MBSubmit: 174 Solved: 135[Submit][Status][Dis ...
- bzoj 5092 [Lydsy1711月赛]分割序列 贪心高维前缀和
[Lydsy1711月赛]分割序列 Time Limit: 5 Sec Memory Limit: 256 MBSubmit: 213 Solved: 97[Submit][Status][Dis ...
- bzoj 5093 [Lydsy1711月赛]图的价值 NTT+第二类斯特林数
[Lydsy1711月赛]图的价值 Time Limit: 30 Sec Memory Limit: 256 MBSubmit: 245 Solved: 128[Submit][Status][D ...
- bzoj 5092: [Lydsy1711月赛]分割序列
5092: [Lydsy1711月赛]分割序列 Time Limit: 5 Sec Memory Limit: 256 MBSubmit: 219 Solved: 100[Submit][Stat ...
- 【BZOJ 1419】Red is good [概率DP]
我 是 Z Z 概率好玄啊(好吧是我太弱.jpg Description 桌面上有R张红牌和B张黑牌,随机打乱顺序后放在桌面上,开始一张一张地翻牌,翻到红牌得到1美元,黑牌则付出1美元.可以随时停止翻 ...
- BZOJ 1246 & 有点不一样的概率DP
题意: 题意够坑的啊... 一个色子有n个面,第k次掷出一个加上这个k.求掷出所有面的期望值. 我一直以为值是色子面上的... 那么问题来了在色子面上怎么做...n还是1w级别... SOL: 对着理 ...
- bzoj 2553 [BeiJing2011]禁忌——AC自动机+概率DP+矩阵
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2553 看了题解才会…… 首先,给定一个串,最好的划分方式是按禁忌串出现的右端点排序,遇到能填 ...
- BZOJ.4832.[Lydsy1704月赛]抵制克苏恩(期望DP)
题目链接 \(f[s][i][j][k]\)表示还剩\(s\)次攻击,分别有\(i,j,k\)个血量为\(1,2,3\)的奴隶主时,期望受到伤害. 因为期望是倒推,所以这么表示从后往前求,注意\(a, ...
随机推荐
- 【Hadoop】配置环境-伪分布式
目录 1.Linux设置静态IP地址 2.修改主机名和映射文件 3.SSH免密码配置 4.Linux系统JDK的安装和配置 5.Hadoop伪分布式配置和测试 1.Linux设置静态IP地址 1.在L ...
- 环形链表II 142 使用快慢指针(C++实现)
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode ...
- codeforces 845A Chess Tourney
参考:https://blog.csdn.net/zhongyuchen/article/details/77478039 #include <iostream> #include < ...
- [BZOJ1040][ZJOI2008]骑士(树形DP)
对于一个联通块内,有且只有一个环,即n个点n条边 那么找到那个环,然后任意断一条边,这个联通块就变成一棵树了,然后做树形DP就行了 对于断的边要记录下来DP时特判 Code #include < ...
- Create Fiori List App Report with ABAP CDS view – PART 2
In the Part 1 blog, we have discussed below topics CDS annotations for Fiori List Report. How to cre ...
- Apache 配置说明
ServerRoot ServerRoot: The top of the directory tree under which the server's configuration, error, ...
- ABP官方文档
https://aspnetboilerplate.com/Pages/Documents/Introduction
- 今天买了个pro,开始ios开发
今天买了个mac pro 开始ios开发啦,爽!
- restAssured + TestNG测试接口,以下是一个get 请求。
package Elaine.Test.G.APITest; import org.testng.Assert;import org.testng.annotations.BeforeTest;imp ...
- Python简要标准库(5)
hashlib Python的hashlib提供了常见的摘要算法,如MD5,SHA1等等. 基本的生成MD密匙的函数 import hashlib md5 = hashlib.md5() md5.up ...