CSU 1265:dice (Math AH)

Source: Internet
Author: User

Title Link: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1265


Description

An example of a traditional dice are a rounded cube with each of its six faces showing a different number of dots from 1 t o 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 a dices which both with six faces. Can you tell us the probability, the sum points of the dices equals S when we thrown?

Input

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

For each test case, there was only a line with one integer S (2 <= s <=), which has the same meaning as above.

Output

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

Print a blank line after each test case.

Sample Input
223
Sample Output
0.0277780.055556
HINT

Source

Seventh session of university student Program design Competition-warm-up


The code is as follows:

#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 (Math AH)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.