Card Game (First Edition) calculates expectations

Source: Internet
Author: User
Tags cas

Title Link: Card Game (First Edition)


Exercises

Emmmmmm, the match time and teammate scratching also did not write out, sure enough his math in the college entrance examination and returned to the teacher.

The first thing I always wanted was expectation = 1* (probability of getting one point) + (probability of getting two points) + (probability of getting three points) + .... + N (probability of N);

Of course, this practice did not come out.

In fact, should think so, two people each round from the card heap each draw 1 cards, each round fat win probability is 1/2, because each draw two cards, the first card than the second card big probability is 1/2. It is said that each round of fat win the same probability is 1/2, so can expect = 1* (*n) = N/2;

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN = 10000100;
BOOL VIS[MAXN];
int main ()
{
    int caset,cas=0;scanf ("%d", &caset);
    while (caset--)
    {
        int n;scanf ("%d", &n);
        for (int i=0,x;i<2*n;i++) 
scanf ("%d", &x);
        printf ("Case%d:%.2f\n", ++CAS,1.0*N/2);
    }
    return 0;
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.