1383 bayberry conspiracy

Source: Internet
Author: User
Description

Background]

2008.11.16

In the Mr Lv organization, the 3721 class held a group dumplings activity in the dining room of SAT :)

This event was a great success and everyone was very happy. The so-called "Hangzhou, Beijing Airlines ".

After coming down, someone developed a set of exercise questions based on the activity ......

---------------------------------------------------------------------

How are there bayberry in dumplings?

It's mr. lv's idea ...... It's just to replace the colored "coin" in the traditional dumplings with the edible item "Yangmei ......

Is it good to eat bayberry? Not necessarily. This time ......

This is the end ......

The person who eats Yangmei is arranged into a column to extract a number, 1-9;

Then the host announced the "handling" method for each number's kiss;

The best thing is to receive the prize directly;

You can receive the prize only when you have to answer questions;

There are also punishments for drinking vinegar, soy sauce ......

The most vicious thing is ...... Choose an individual to feed a girl (male) friend with dumplings, as if he or she didn't say he or she had to choose the opposite sex ......

For this queue, the processing process is still a process, from the first of the queue to the N;

Now the problem is: small x ranks at the M number. He knows that there are only K gifts. There are two groups of people in front of Him who may receive the prize. If the number selected is the 1, if the number 100% is used, you can get a gift (provided that there is still the remaining gift). If the number 2 is selected, answer the question. He assumes that the person has a 1/2 chance to get the prize; other numbers have no Prize;

Of course, this rule also applies to Xiao x himself;

John wants to know the probability that he will receive the prize, expressed in the form of scores;

Input

The first line contains an integer T, indicating that there are T groups of test data;

The following T groups of data are in the following format:

The first behavior contains three integers, n, m, and K. The meaning is shown in the topic description;

The second act is an integer of N. Each integer ranges from 1 ~ 9;

Ensure that N is no greater than 147 (why? Guess), K is not greater than 10;

Output

Please output the answer in the form of a/B in the score form, requiring the interconnectivity between A and B (or a is 1, B is an integer)

If the probability is 0, a 0 is output;

Sample Input
1
8 7 4
2 2 3 1 4 2 1 5
Sample output
7/8

The main research points of this question are the probability and the least common factor.

# Include <iostream> # include <stdio. h> using namespace STD; int FAC (int A) {int res = 1; int I; for (I = 2; I <= A; I ++) res * = I; return res;} int CAL (int A, int B) {int res = 1; int I; for (I = A; I> A-B; I --) RES * = I; for (I = 2; I <= B; I ++) RES/= I; return res;} int gcd (int, int B) {while (B! = 0) {int temp = B; B = A % B; A = temp;} return a;} int main () {int n, m, K; int T; scanf ("% d", & T); While (t --) {scanf ("% d", & N, & M, & K ); int I; int A [151]; for (I = 1; I <= N; I ++) {scanf ("% d", & A [I]);} int ones = 0; int twos = 0; for (I = 1; I <m; I ++) {if (a [I] = 1) {ones ++;} if (a [I] = 2) {twos ++;} int remains = k-ones; if (remains <= 0 | A [m]> 2) {printf ("0 \ n"); continue;} If (remains> twos) {if (a [m] = 1) printf ("1/1 \ n"); if (a [m] = 2) printf ("1/2 \ n "); continue;} int x = 0; // molecule for (I = 0; I <remains; I ++) x ++ = CAL (twos, I ); int y = 1 <twos; // denominator int bp; if (a [m] = 2) y = y * 2; BP = gcd (Y, X ); y = y/BP; X = x/BP; printf ("% d/% d \ n", x, y);} return 0 ;}

 

 

Related Keywords:

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.