zoukankan      html  css  js  c++  java
  • 组合问题(登机)

    https://nanti.jisuanke.com/t/41288

    题意:两个问题。

    第一个问题:n个人编号为1~n,依次登机,只有编号1不知道坐哪(随便坐),其他人都知道自己的座位,如果自己的座位被占了就随便坐。

    问最后一个人坐对自己位置的概率。

    第一个问题:与第一个问题相同,就是每个人登机是随机的。

    https://blog.csdn.net/xigongdali/article/details/81510551。

    //#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <algorithm>
    #include <iostream>
    #include <algorithm>
    #include <iostream>
    #include <cstdio>
    #include <string>
    #include <cstring>
    #include <stdio.h>
    #include <queue>
    #include <stack>;
    #include <map>
    #include <set>
    #include <string.h>
    #include <vector>
    #define ME(x , y) memset(x , y , sizeof(x))
    #define SF(n) scanf("%d" , &n)
    #define rep(i , n) for(int i = 0 ; i < n ; i ++)
    #define INF  0x3f3f3f3f
    #define mod 1000000007
    #define PI acos(-1)
    using namespace std;
    typedef long long ll ;
    
    
    int main()
    {
        int t ;
        scanf("%d" , &t);
        int cnt = 0 ;
        while(t--)
        {
            int n , m ;
            scanf("%d%d" , &n , &m);
            printf("Case #%d: " , ++cnt);
            if(n == 1)
                printf("1.000000 ");
            else
                printf("0.500000 ");
            printf("%.6lf
    " , (double)(m+1)/(2*m));
        }
    
        return 0;
    }
  • 相关阅读:
    生成器
    装饰器
    类的特殊方法
    获取对象的信息之反射
    获取对象信息之内置函数dir()
    获取对象的信息之内置函数type()
    获取对象的信息之内置函数issubclass() 和 isinstance()
    生成可下载图片
    js数组常用方法
    sql存储过程基本语法
  • 原文地址:https://www.cnblogs.com/nonames/p/11443967.html
Copyright © 2011-2022 走看看