zoukankan      html  css  js  c++  java
  • NYOJ926(概率)

    题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=926

    设最终A获胜的概率为P,则B获胜的概率为1-P;

    因此我们只需要考虑A获胜的概率即可;

    又由题意可知每一轮中他们做对题目的概率是不变的;

    可分两种情况讨论:一是在当前局中A获胜了,用p1表示,则p1=(a%)*(1-b%);

    或者当前局为平局,用p2表示其概率,则p2=(a%)*(b%),即A只能在之后的游戏中获胜,当前局轮白了,对之后的胜负没有影响,即A此时的胜率仍然为P;

    由此可得:p=p1+p2*p;即p=p1/(1-p2);带入p1,p2可得:p=(100*a-a*b)/(10000-a*b);

    ac代码:

     1 #include <bits/stdc++.h>
     2 #include <iostream>
     3 #include <queue>
     4 #include <stdio.h>
     5 #include <string.h>
     6 #include <algorithm>
     7 #include <string>
     8 #include <math.h>
     9 #include <set>
    10 #include <map>
    11 #define mod  1000000007
    12 #define MAXN 100000+10
    13 #define INF 1000000000
    14 #define eps 10e-6
    15 #define ll long long
    16 using namespace std;
    17 
    18 bool cmp(int a, int b)
    19 {
    20     return a > b;
    21 }
    22 
    23 //******************************************************************************
    24 
    25 int main(void)
    26 {
    27     std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    28     int t;
    29     cin >> t;
    30     while(t--)
    31     {
    32         int a, b;
    33         cin >> a >> b;
    34         int x=100*a-a*b, y=10000-a*b, gg=__gcd(x, y);
    35         cout << x/gg << "/" << y/gg << " " << (y/gg-x/gg) << "/" << y/gg << endl;
    36     }
    37     return 0;
    38 }
  • 相关阅读:
    uva11922splay
    获取的二维数组排序
    二维数组排序
    $.extend
    <eq>标签
    datagrid时间插件
    id=%d是什么意思呢?
    获得某一月的第一天,最后一天
    数组合并
    phpexcel 导入导出excel表格
  • 原文地址:https://www.cnblogs.com/geloutingyu/p/5924739.html
Copyright © 2011-2022 走看看