Three Dices: THREDICE

link: https://www.codechef.com/CU1PP0006/problems/THREDICE

Read problem statements in RussianMandarin ChineseBengali, and Vietnamese as well.

There are three people, and each of them has an unbiased 66-sided die. The result of rolling a die will be a number between 11 and 66 (inclusive) with equal probability.

The three people throw their dice simultaneously. In this game, the third person wins only if his number is strictly greater than the sum of the other two numbers. Given that the first person rolls the value XX and the second person rolls the value YY, what is the probability the third person will win?

Solution:

#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin>>t;
    while(t--)
    {
        int x,y;
        cin>>x>>y;
        double poss=6-(x+y);
        poss=max(poss,0.0);
        double ans=poss/6;
        cout<<fixed<<setprecision(10)<<ans<<"\n";
    }
    return 0;
}
See also  Pair of primes: PAIRPR1