poj 6243 Dogs and Cages】的更多相关文章

Dogs and Cages Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 56    Accepted Submission(s): 40Special Judge Problem Description Jerry likes dogs. He has N dogs numbered 0,1,...,N−1 . He also ha…
题意:在1—n的数字,放入编号为1—n的框中,每个框只放一个数字,问数字与所放的框的编号不同的个数的期望值. 思路:在1—n中任选一个数字,设为k 那么 k 排到非k编号的框中的方案数为 n!-(n-1)!(n!是所有数的全排列,(n-1)!是k放在k框中的全排列) 那么有n个数字,就是n*( n! - (n-1)! )  而样本空间是 n!因为,有n个数随机排列的总得方案数‘  ,对公式化简得 n-1 ac代码: #include<iostream> using namespace std;…
题面 题意:问1~n的所有的排列组合中那些,所有数字 i 不在第 i 位的个数之和除以n的全排,即题目所说的期望,比如n=3 排列有123(0),132(2),231(3),213(2),312(3),321(2)  ans=(0+2+3+2+3+2)/6=2 题解: 发现当1在1的位置上的时候,有 (n-1) ! 种情况 那么1不在它的位置上有 n! - (n-1) !  种情况 一共有 n 个这样的数字,所以乘n 最后除以 n!,化简得到 n-1 #include<bits/stdc++.h…
A - Dogs and Cages 水. #include <bits/stdc++.h> using namespace std; int t; double n; int main() { scanf("%d", &t); ; kase <= t; ++kase) { scanf("%lf", &n); printf(); } ; } B - Same Digit 留坑. C - Rich Game 题意:有两个人,A可以控制…
比赛链接:传送门 前期大顺风,2:30金区中游.后期开题乏力,掉到银尾.4:59绝杀I,但罚时太高卡在银首. Problem A - Dogs and Cages 00:09:45 (+) Solved by Dancepted 算了半天发现就是n-1,被队友喷死,差点气哭. Problem E - Evil Forest 00:16:54 (+) Solved by xk xk大喊签到,就过了. 代码: #include <iostream> #include <cmath> #…
/************************************************************* 题目: Feed the dogs(poj 2761) 链接: http://poj.org/problem?id=2761 题意: 给一个数列,在给一些区间,求这些区间第k小的值,这些 区间没有包含关系,也就是说如果La>Lb那么Ra>Rb; 算法: treap树 思路: 由于这些区间没有包含关系,把这些区间排序后从左边 开始计算,每计算一个区间把前面多余数删除,这样…
Description Wind loves pretty dogs very much, and she has n pet dogs. So Jiajia has to feed the dogs every day for Wind. Jiajia loves Wind, but not the dogs, so Jiajia use a special way to feed the dogs. At lunchtime, the dogs will stand on one line,…
Feed the dogs Time Limit: 6000MS   Memory Limit: 65536K Total Submissions: 16860   Accepted: 5273 Description Wind loves pretty dogs very much, and she has n pet dogs. So Jiajia has to feed the dogs every day for Wind. Jiajia loves Wind, but not the…
                                                            Feed the dogs Time Limit: 6000MS   Memory Limit: 65536K Total Submissions: 20634   Accepted: 6494 Description Wind loves pretty dogs very much, and she has n pet dogs. So Jiajia has to feed…
主席树,区间第$k$大. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<map> #include<set> #include<queue&…