LOTT - Xổ số

Tác giả: flashmt

Ngôn ngữ: C++

#include<iostream>
#include<string>
using namespace std;

long long c(int x,int y)
{
     if (x>y) return 0;
     if (x==0) return 1;
     return c(x-1,y)*(y-x+1)/x;
}

int main()
{
    string s;
    int n;
    double x,y;
    while (1) 
    {
          cin >> s;
          if (s=="[END]") return 0;
          if (s=="[CASE]") 
          {
              cin >> n;
              x=c(5,n)*3125+c(3,n-1)*1250*n+c(2,n-1)*500*n;
              y=c(5,5*n);   
              cout << 1-x/y << endl;
          }
    }
    return 0;
}

Download