标签:sample not first des cep dig exp main 学生
题目链接:http://acm.fzu.edu.cn/problem.php?pid=2265
第七届福建省赛重现赛D题,概率计算不过挺有技巧的,问了acdart兄才恍然大悟(分明看了好长时间。。。)
acdart原话:
1 const int maxn = 10010; 2 int n, a[maxn], b[maxn]; 3 4 int main(){ 5 int t; 6 scanf("%d", &t); 7 for(int ii = 1; ii <= t; ii++){ 8 scanf("%d", &n); 9 for(int i = 0; i < n; i++){ 10 scanf("%d", &a[i]); 11 } 12 for(int i = 0; i < n; i++){ 13 scanf("%d", &b[i]); 14 } 15 sort(b, b + n); 16 int ans = 0; 17 for(int i = 0; i < n; i++){ 18 ans += upper_bound(b, b + n, a[i]) - b; 19 } 20 printf("Case %d: %.2f\n", ii, 1.0 * ans / n); 21 } 22 }
题目:
Fat brother and Maze are playing a kind of special (hentai) game with some cards. In this game, every player gets N cards at first and these are their own card deck. The game goes for N rounds and in each round, Fat Brother and Maze would draw one card from their own remaining card deck randomly and compare for the integer which is written on the cards. The player with the higher number wins this round and score 1 victory point. And then these two cards are removed from the game such that they would not appear in the later rounds. As we all know, Fat Brother is very clever, so he would like to know the expect number of the victory points he could get if he knows all the integers written in these cards.
Note that the integers written on these N*2 cards are pair wise distinct. At the beginning of this game, each player has 0 victory point.
The first line of the data is an integer T (1 <= T <= 100), which is the number of the text cases.
Then T cases follow, each case contains an integer N (1 <=N<=10000) which described before. Then follow two lines with N integers each. The first N integers indicate Fat Brother’s cards and the second N integers indicate Maze’s cards.
All the integers are positive and no more than 10000000.
For each case, output the case number first, and then output the expect number of victory points Fat Brother would gets in this game. The answer should be rounded to 2 digits after the decimal point.
FZUOJ 2265 Card Game (Second Edition)
标签:sample not first des cep dig exp main 学生
原文地址:http://www.cnblogs.com/bolderic/p/7208647.html