链接:

https://codeforces.com/gym/102394/problem/K

题意:

DreamGrid is the keeper of n rabbits. Initially, the i-th (1≤i≤n) rabbit has a weight of wi.

Every morning, DreamGrid gives the rabbits a carrot of weight 1 and the rabbits fight for the only carrot. Only one rabbit wins the fight and eats the carrot. After that, the winner's weight increases by 1. The whole process of fighting and eating ends before the next morning.

DreamGrid finds that the heavier a rabbit is, the easier it is to win a fight. Formally, if the weights of the rabbits are w′1,w′2,…,w′n before a fight, the probability that the i-th rabbit wins the fight is

w′i∑j=1nw′j

He wants to know the expected weight of every rabbit after k days (k carrots are given and eaten).

思路:

每次选一个,在下一次是总体的概率不变,直接概率乘即可。

代码:

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 1e5+10; int Val[MAXN];
int n, k; int main()
{
ios::sync_with_stdio(false);
int t;
scanf("%d", &t);
while(t--)
{
scanf("%d%d", &n, &k);
LL sum = 0;
for (int i = 1;i <= n;i++)
scanf("%d", &Val[i]), sum += Val[i];
for (int i = 1;i <= n;i++)
{
double add = (double)Val[i]/(double)sum;
add = add*k;
printf("%.6lf ", add+Val[i]);
}
puts("");
} return 0;
}

The 2019 China Collegiate Programming Contest Harbin Site K. Keeping Rabbits的更多相关文章

  1. The 2019 China Collegiate Programming Contest Harbin Site

    题解: https://files.cnblogs.com/files/clrs97/HarbinEditorialV2.zip Code: A. Artful Paintings /* let x= ...

  2. The 2019 China Collegiate Programming Contest Harbin Site F. Fixing Banners

    链接: https://codeforces.com/gym/102394/problem/F 题意: Harbin, whose name was originally a Manchu word ...

  3. The 2019 China Collegiate Programming Contest Harbin Site J. Justifying the Conjecture

    链接: https://codeforces.com/gym/102394/problem/J 题意: The great mathematician DreamGrid proposes a con ...

  4. The 2019 China Collegiate Programming Contest Harbin Site I. Interesting Permutation

    链接: https://codeforces.com/gym/102394/problem/I 题意: DreamGrid has an interesting permutation of 1,2, ...

  5. 模拟赛小结:The 2019 China Collegiate Programming Contest Harbin Site

    比赛链接:传送门 上半场5题,下半场疯狂挂机,然后又是差一题金,万年银首也太难受了. (每次银首都会想起前队友的灵魂拷问:你们队练习的时候进金区的次数多不多啊?) Problem J. Justify ...

  6. The 2017 China Collegiate Programming Contest, Hangzhou Site Solution

    A: Super_palindrome 题面:给出一个字符串,求改变最少的字符个数使得这个串所有长度为奇数的子串都是回文串 思路:显然,这个字符串肯定要改成所有奇数位相同并且所有偶数位相同 那统计一下 ...

  7. 2019 China Collegiate Programming Contest Qinhuangdao Onsite

    传送门 D - Decimal 题意: 询问\(\frac{1}{n}\)是否为有限小数. 思路: 拆质因子,看是不是只包含2和5即可,否则除不尽. Code #include <bits/st ...

  8. 2019 China Collegiate Programming Contest Qinhuangdao Onsite F. Forest Program(DFS计算图中所有环的长度)

    题目链接:https://codeforces.com/gym/102361/problem/F 题意 有 \(n\) 个点和 \(m\) 条边,每条边属于 \(0\) 或 \(1\) 个环,问去掉一 ...

  9. The 2015 China Collegiate Programming Contest A. Secrete Master Plan hdu5540

    Secrete Master Plan Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Othe ...

随机推荐

  1. Struts笔记3

    struts标签 form表单标签 Action:请求地址.直接写动作名称,不用写contextPath <s:form action="/user/register.action&q ...

  2. Python列表生成式测试

    print('*'*50) list1 = list(range(1,6)) print(list1) del(list1) #range(1,20) 按顺序生成列表 list1 = [] for x ...

  3. Linux基础-04-权限

    1. 查看文件的权限 1) 使用ls –l命令查看文件上所设定的权限. -rw-r--r-- 1 root root 605 Mar 18 20:28 .jp1.tar.gz 权限信息 属主 属组 文 ...

  4. VNC的使用

    1. 安装 rpm -ivh tigervnc-server--.el6.x86_64.rpm 如果rpm安装时发现有依赖,建议直接使用yum安装,轻松解决依赖问题: yum install tige ...

  5. Github相关问题集锦

    问题 对于我们国内用户,有时候浏览器在进入github网站时,会出现无法加载或加载很慢的问题,针对这一问题,很是头疼,为解决这一问题,在网上搜索到的解决方法如下: 解决方案 修改hosts文件,在ho ...

  6. 使用 pykafka 进行消费

    kafka连接脚本 环境:python3,用到的模块有 pykafka,kazoo # coding=utf-8 import pykafka class KafkaReaderThread(obje ...

  7. springboot下@webfilter的使用

    启动类加了@ServletComponentScan,无论过滤器类加不加@Componment urlPatterns = {"/test/*"}都可以生效 单使用@Compone ...

  8. 【转载】Sqlserver使用Right函数从最右边向前截取固定长度字符串

    在SQL语句查询过程中,Sqlserver支持使用LEFT().RIGHT().SUBSTRING()等几个函数对字符串进行截取操作,其中Left函数表示从开始字符向后截取多少个字符,Right函数表 ...

  9. $.ajaxSetup()与$.ajax()区别

    ajaxSetup()其使用方法与ajax()并无区别,只是在其之后的ajax()不用再重复添加相同参数,节省了代码量. 附:API中关于jQuery.ajaxSetup([options])的描述和 ...

  10. ubuntu下使用JNI Java调用C++的例子

    TestJNI.java public class TestJNI { static{ System.load("/home/buyizhiyou/workspace/JNI/src/lib ...