nyoj-probability calculation

Source: Internet
Author: User

Probability calculation time limit: +Ms | Memory Limit:65535KB Difficulty:1
Describe
A and B two people take part in an answer contest. The process of the game is probably a and B two people take turns answer, a first answer. Once someone does not answer the question correctly, the opponent wins immediately. Therefore, two people in the game to a certain extent depends on the luck, I hope that they will not meet the problem later, and the opponent will encounter the problem. In order to simplify the problem, we assume that the probability of a correct problem is a%, b the probability of the problem is b%, ask the last A, B to win the game of the probability of each?
Input
Enter an integer t to indicate that there is a T group of test data.
Next T line, each line input two integers a, B, indicating that A and B wins the probability of a% and b% respectively, of which 0 <= a, b <=, AB < 10000.
Output
each set of test data output a row, respectively A and b the probability of the final win, the middle with 1 spaces separated. The probability is expressed in the form of the simplest fraction x/y (note that even if Y is 1, it should be written in x/1 form). The detailed output is shown in the sample example.
Sample input
2100 050 50
Sample output
1/1 0/11/3 2/3
Source

Beihang Network Qualifiers

#include <stdio.h> int GCD (int a,int b) {return!b?a:gcd (b,a%b);} int main () {int t;scanf ("%d", &t), while (t--) {int a,b,am,an,bm;scanf ("%d%d", &a,&b); if (a==0&&b) printf ("0/1 1/1\n"), else if (a&&b==0) printf ("1/1 0/1\n"), else if (a==0&&b==0) printf ("0/1 0/1\n"); else {am=a* (100-b); an=10000-a*b;bm=an-am;    printf ("%d/%d%d/%d\n", AM/GCD (Am,an), AN/GCD (Am,an), BM/GCD (Bm,an), AN/GCD (Bm,an));}    } return 0;}


nyoj-probability calculation

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.