首页 > 代码库 > CSU 1265: Dice (数学啊 )

CSU 1265: Dice (数学啊 )

题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1265


Description

An example of a traditional dice is a rounded cube, with each of its six faces showing a different number of dots from 1 to 6. When thrown or rolled, the dice comes to rest showing on its upper surface a random integral points from one to six, each value being equally likely.

----wikipedia

Now we have two dices which both have six faces. Can you tell us the probability that the sum points of two dices equals S when we thrown?

Input

There is an integer T (1 <= T <= 11) in the first line, means there are T test cases in total.

For each test case, there is only one line with one integer S (2 <= S <= 12), which have the same meaning as above.

Output

For each test case, you should print the probability that the sum points of two dices equals S when we thrown. The answer should be in one line and rounding to 6 decimals.

Print a blank line after each test case.

Sample Input

2
2
3

Sample Output

0.027778

0.055556

HINT

Source

中南大学第七届大学生程序设计竞赛-热身赛


代码如下:

#include <cstdio>
int main()
{
    int t;
    int sum;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&sum);
        int cont=0;
        for(int i = 1; i <= 6; i++)
        {
            for(int j = 1; j <= 6; j++)
            {
                if(i+j==sum)
                    cont++;
            }
        }
        printf("%.6lf\n\n",cont/36.0);
    }

    return 0;
}


CSU 1265: Dice (数学啊 )