Nine degrees OJ 1363 happy landlords (simulation, careful)

Source: Internet
Author: User

Topic 1363: Happy bucket landlord

time limit:1 seconds

Memory limit:32 MB

Special question: No

submitted:770

Resolution:175

Title Description:

If you have ever played a game of fun fighting landlords, you must know that there is a button with "hint" function. If you do not know that you are now in the hands of the card is bigger than the brand, and you do not bother to look at your hands a card. At this point you can click on the "Hint" button and the system will tell you if you have such a card.

If you are a person who likes to challenge, you will be able to write a program that allows it to implement the "hint" button in the landlord.

Now, we have the "hint" button has the function of simplifying, it just need to find out in the home card is "three with a pair" in case your hand is bigger than the card.

Input:

Each set of test data may have multiple sets of inputs, for each set of inputs,

The first line of input includes an integer N (1<=n<=18), which represents the number of cards left in your hand.

The next line consists of n numbers (1-13, which represent the a-k in poker), and the n numbers you have are unordered.

The next line consists of five numbers, the first three numbers are the same, and the last two numbers are the same, representing the "three-band pair".

Output:

If you have a card in hand than the home of the "three with a pair" big, the output of such a card, the output format and input in the same third line, that is, five numbers: The first three is the same, the latter two are the same, representing your hands of the "three with a pair." If you do not have a "three with a pair" big cards in your hand, please output "My God".

Sample input:
81 6 4 8 4 7 6 43 3 3 9 981 6 4 8 4 7 6 48 8 8 2 2
Sample output:
4 4 4 6 6My God
Tips:

1. "Three with a pair": three cards of the same number + two cards of the same number, at which time the five cards can be out at the same time. The rules for "three bands" are as follows--just compare the size of the number of three cards of the same number, without having to consider the size of the number of two cards of the same number. For example: "Three 5 with two 3", larger than "three 4 with two 8".

2. As we all know, a and 2 in playing cards are bigger than 3-k, please do the processing in the program.

3. If you have a variety of cards in the hand can be more than the home of the "three with a pair" big, you need to choose the "three with a pair" in the three of the same card number of the smaller type of the way out. For example, if the card is 3 3 3 4 4, and you now have 6 6 6 7 7 7 cards, the cards you need are 6 6 6 6 7 instead of 7 7 7 7 6, and if the three bands have the smallest number, you need to output the result with the least pair of values.

4. You can rest assured that our cards and cards will not appear in the size of the king.


#include <string.h> #include <stdio.h>int a[20];int b[5];int flag[20];void i_sort (int a[],int n) {for (int i=1        ; i<n;++i) {int value=a[i];        int j=i-1;            while (J>=0&&a[j]>value) {a[j+1]=a[j];        j--;    } A[j+1]=value;    }}int Main (int argc, char *argv[]) {int N;        while (~SCANF ("%d", &n)) {memset (a,0,sizeof (a));        Memset (b,0,sizeof (b));        memset (flag,0,sizeof (flag));            for (int i=0;i<n;++i) {scanf ("%d", &a[i]);            if (a[i]==1) a[i]=14;        if (a[i]==2) a[i]=15;        } i_sort (A,n);            for (int i=0;i<5;++i) {scanf ("%d", &b[i]);            if (b[i]==1) b[i]=14;        if (b[i]==2) b[i]=15;        } int f1=0;        int f2=0;                for (int i=0;i<=n-3;++i) {if (a[i]>b[0]&&a[i]==a[i+1]&&a[i]==a[i+2]) {           Flag[i]=flag[i+1]=flag[i+2]=1;     F1=a[i];            Break }} for (int i=0;i<=n-2;++i) {if (flag[i]==0&&a[i]==a[i+1]) {f2=a                [i];            Break            }} if (f1!=0&&f2!=0) {if (f1==14) f1=1;            if (f1==15) f1=2;            if (f2==14) f2=1;            if (f2==15) f2=2;        printf ("%d%d%d%d\n", F1,F1,F1,F2,F2);    } else printf ("My god\n"); } return 0;}



Nine degrees OJ 1363 happy landlords (simulation, careful)

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.