Round Table problem hdu 4841 PE ....

Source: Internet
Author: User
 Round Table Issues Time limit:3000/1000 MS (java/others) Memory limit:65535/32768 K (java/others)
Total submission (s): 466 accepted Submission (s): 157


The Problem Description Round table sits around 2n individuals. where n is a good person, and the other n is a bad person. If the number of persons from the first person is counted to a person, the person shall be executed immediately, and then the number of persons who are executed shall be counted and the number of M will be executed. In this way the people who sit around the round table are continually executed. How to arrange these good and bad seats in advance, so that after the death of N individuals, the round table around the remaining n individuals are all good people.
Input multiple sets of data, each set of data input: The number of good and bad People N (<=32767), Step m (<=32767);
Output 2n uppercase letters for each set of data, ' G ' means good guy, ' B ' means bad guy, 50-letter line, no white space characters allowed. A blank line is left between adjacent data.
Sample Input
2 3 2 4
Sample Output
GBBG BGGB process is relatively simple, direct simulation of the process of selecting people is good. The main problem is the final output. The first three or four times, are PE. It was later discovered that for a set of data, after 50 characters, if there are characters that do not require a blank line, only the output between the two sets of data will be blank. Another place that does not understand is that the topic said the data range to 32767, I tested it myself, entered two 32767. And then the long wait is obviously going to be timed out ... But the submission went up without .... Does the test data not.
#include <stdio.h>
#include <string.h>

int n,m,i,j,k,flag = 0;
int table[100000];
Char place[100000];

int main ()
{while
    (~scanf ("%d%d", &n,&m))
    {
        memset (table,0,sizeof (table));
        i = k = 0;
        j = N;
        while (n)
        {
            if (table[i] = = 0) k++;
            if (k = = m)
            {
                table[i] = 1;
                k = 0;
                n--;
            }
            i++;
            if (i = = 2 * j) i = 0;
        }
        for (i = 0; i < 2*j i++)
        {
            if (table[i)) printf ("B");
            else printf ("G");
            Flag = 0;
            if ((i+1)% = 0)  {printf ("\ n"); flag = 1;}
        }
        if (!flag) printf ("\ n");
        printf ("\ n");

    }
    return 0;
}


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.