The 2019 China Collegiate Programming Contest Harbin Site K. Keeping Rabbits
链接:
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的更多相关文章
- The 2019 China Collegiate Programming Contest Harbin Site
题解: https://files.cnblogs.com/files/clrs97/HarbinEditorialV2.zip Code: A. Artful Paintings /* let x= ...
- 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 ...
- 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 ...
- 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, ...
- 模拟赛小结:The 2019 China Collegiate Programming Contest Harbin Site
比赛链接:传送门 上半场5题,下半场疯狂挂机,然后又是差一题金,万年银首也太难受了. (每次银首都会想起前队友的灵魂拷问:你们队练习的时候进金区的次数多不多啊?) Problem J. Justify ...
- The 2017 China Collegiate Programming Contest, Hangzhou Site Solution
A: Super_palindrome 题面:给出一个字符串,求改变最少的字符个数使得这个串所有长度为奇数的子串都是回文串 思路:显然,这个字符串肯定要改成所有奇数位相同并且所有偶数位相同 那统计一下 ...
- 2019 China Collegiate Programming Contest Qinhuangdao Onsite
传送门 D - Decimal 题意: 询问\(\frac{1}{n}\)是否为有限小数. 思路: 拆质因子,看是不是只包含2和5即可,否则除不尽. Code #include <bits/st ...
- 2019 China Collegiate Programming Contest Qinhuangdao Onsite F. Forest Program(DFS计算图中所有环的长度)
题目链接:https://codeforces.com/gym/102361/problem/F 题意 有 \(n\) 个点和 \(m\) 条边,每条边属于 \(0\) 或 \(1\) 个环,问去掉一 ...
- 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 ...
随机推荐
- [Visual Studio] - 使用 Fiddler 时,禁止监控 VSHub 请求的方法
背景 VS + Fiddler 调试 WebAPI,监控请求包含大量 VSHub Request.http://localhost:49161/vshub/bb195f2e0d5c4765b9411f ...
- sublime自动格式化方法
Sublime 工具自带代码格式化的功能,但在某些场景下格式化代码后并不是我们想要的代码格式,且是点击保存ctrl+s才触发的格式代码事件,so,为关闭点击ctrl+s格式代码,我们需要改命令 sav ...
- PAT(B) 1062 最简分数(Java)
题目链接:1062 最简分数 (20 point(s)) 题目描述 一个分数一般写成两个整数相除的形式:N/M,其中 M 不为0.最简分数是指分子和分母没有公约数的分数表示形式. 现给定两个不相等的正 ...
- linux终端提示符修改
Linux主机名莫名其妙的由@myhostname变成了@bogon了之后 1.在linux下添加一个127.0.0.2名叫bogon的主机此方法使用后,bogon主机名得以解析,使用的主机名仍为bo ...
- IIS不能下载config配置文件的解决方法
之前作程序升级的时候,需要从服务端下载后缀为config的配置文件,结果程序抛出404异常.后来百度才知道,是IIS禁止下载config文件的原因.在这里记录一下解决方法. 在我的电脑,右键管理,打开 ...
- docker 宿主机与容器直接文件移动命令
1.将容器中的文件复制到宿主机 我们把容器中的 nginx 目录整个复制到 宿主机/usr/local/nginx 目录下,使用如下命令: docker cp nginx_test: /etc/ng ...
- codeforce 849D. Make a Permutation!
D. Make a Permutation! time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- C#在txt类文件中追加内容
string path = "test.txt"; FileStream mystream = new FileStream(path, FileMode.OpenOrCreate ...
- NEST指定id
1.默认以Id属性为Id,无Id属性则自动生成 2.可通过属性标签指定Id [ElasticsearchType(IdProperty = nameof(last_name))] public cla ...
- 移动端调试工具Vconsole
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...