直接暴力dp就行……f(i,j)表示前i天集齐j种类的可能性。不超过10000天就能满足要求。

#include<cstdio>
using namespace std;
#define EPS 1e-10
int K,q,p;
double f[10010][1010];
int main()
{
// freopen("d.in","r",stdin);
scanf("%d%d",&K,&q);
f[0][0]=1.0;
for(int i=1;i<=10000;++i)
for(int j=1;j<=K && j<=i;++j)
f[i][j]=f[i-1][j]*((double)j/(double)K)+f[i-1][j-1]*((double)(K-(j-1))/(double)K);
for(int i=1;i<=q;++i)
{
scanf("%d",&p);
for(int j=1;j<=10000;++j)
if(f[j][K]-((double)p/2000.0)>(-EPS))
{
printf("%d\n",j);
break;
}
}
return 0;
}

【概率dp】Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) D. Jon and Orbs的更多相关文章

  1. Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) D. Jon and Orbs

    地址:http://codeforces.com/contest/768/problem/D 题目: D. Jon and Orbs time limit per test 2 seconds mem ...

  2. Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined)

    C题卡了好久,A掉C题之后看到自己已经排在好后面说实话有点绝望,最后又过了两题,总算稳住了. AC:ABCDE Rank:191 Rating:2156+37->2193 A.Oath of t ...

  3. Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) C - Jon Snow and his Favourite Number

    地址:http://codeforces.com/contest/768/problem/C 题目: C. Jon Snow and his Favourite Number time limit p ...

  4. Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) B. Code For 1

    地址:http://codeforces.com/contest/768/problem/B 题目: B. Code For 1 time limit per test 2 seconds memor ...

  5. Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) A B 水 搜索

    A. Oath of the Night's Watch time limit per test 2 seconds memory limit per test 256 megabytes input ...

  6. Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) A. Oath of the Night's Watch

    地址:http://codeforces.com/problemset/problem/768/A 题目: A. Oath of the Night's Watch time limit per te ...

  7. 【博弈论】【SG函数】【找规律】Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) E. Game of Stones

    打表找规律即可. 1,1,2,2,2,3,3,3,3,4,4,4,4,4... 注意打表的时候,sg值不只与剩下的石子数有关,也和之前取走的方案有关. //#include<cstdio> ...

  8. 【基数排序】Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) C. Jon Snow and his Favourite Number

    发现值域很小,而且怎么异或都不会超过1023……然后可以使用类似基数排序的思想,每次扫一遍就行了. 复杂度O(k*1024). #include<cstdio> #include<c ...

  9. 【找规律】Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) B. Code For 1

    观察一下,将整个过程写出来,会发现形成一棵满二叉树,每一层要么全是0,要么全是1. 输出的顺序是其中序遍历. 每一层的序号形成等差数列,就计算一下就可以出来每一层覆盖到的区间的左右端点. 复杂度O(l ...

随机推荐

  1. IE浏览器被固定启动时访问某网页的处理方法

    一.问题的提出 有些windows的GHOST系统在镜像成使用系统后或者正规安装的windows系统在安装金山毒霸.360杀毒软件后,IE浏览器一打开就自动打开某个指定的网站. 二.问题的分析 1.I ...

  2. bzoj 1110 [POI2007]砝码Odw 贪心+进制转化

    [POI2007]砝码Odw Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 661  Solved: 366[Submit][Status][Disc ...

  3. docker compose,link,Odoo

    1.报错: /usr/bin/docker-current: Error response from daemon: driver failed programming external connec ...

  4. linux网络编程系列-TCP/IP模型

    ### OSI:open system interconnection ### 开放系统互联网模型是由ISO国际标准化组织定义的网络分层模型,共七层 1. 物理层:物理定义了所有电子及物理设备的规范, ...

  5. Java并发(8)- 读写锁中的性能之王:StampedLock

    在上一篇<你真的懂ReentrantReadWriteLock吗?>中我给大家留了一个引子,一个更高效同时可以避免写饥饿的读写锁---StampedLock.StampedLock实现了不 ...

  6. RPC-整体概念

    RPC概述 RPC(Remote Procedure Call),即远程过程调用,是一种通过网络从远程计算机程序上请求服务而不需要了解底层网络技术的协议,实现调用远程主机上的方法就像调用本地方法一样. ...

  7. 【Foreign】石子游戏 [博弈论]

    石子游戏 Time Limit: 10 Sec  Memory Limit: 256 MB Description Input Output 输出T行,表示每组的答案. Sample Input 3 ...

  8. [BZOJ1004] [HNOI2008]Cards解题报告(Burnside引理)

    Description 小春现在很清闲,面对书桌上的N张牌,他决定给每张染色,目前小春只有3种颜色:红色,蓝色,绿色.他询问Sun有多少种染色方案,Sun很快就给出了答案.进一步,小春要求染出Sr张红 ...

  9. [Leetcode Week9]Minimum Path Sum

    Minimum Path Sum 题解 原创文章,拒绝转载 题目来源:https://leetcode.com/problems/minimum-path-sum/description/ Descr ...

  10. RabbitMQ消息队列(五): 主题分发

    1. 主题(Topics): fanout模式只能进行简单的广播,direct模式虽然在过滤上进行了一定的提升,但是不能支持复杂的条件, 比如我们的日志消息,现在不仅要知道消息级别,也要知道消息来源. ...