1069. Weibo forward Lottery (a) Pat B real Title

Source: Internet
Author: User
1069. Weibo forward lottery

Xiao-ming Pat a full mark, happy decided to launch a micro-Bo forward lottery, from the forwarded netizens in order every n individual sent a red envelope. Please write a program to help him determine the winning list.

Input Format:

Enter the first line to give three positive integers m (<= 1000), n, and S, respectively, the total number of forwards, the winning interval as determined by xiaoming, and the ordinal number of the first winner (numbering begins at 1). Then the M line, in order, gives the nickname of the Netizen who forwards the microblog (no more than 20 characters, a non-empty string that does not contain a space carriage return).

Note: It may be forwarded several times, but not many times. So if the user in the current winning position has already won the prize, skip him and take down one.

output Format:

Output the winning list in the order you entered, one for each nickname. If no one wins, the output is "Keep going ...". Enter Sample 1:

9 3 2
imgonnawin!
Pickme
pickmememeee
lookhere
imgonnawin!
Tryagainagain
tryagainagain
imgonnawin!
Tryagainagain
Output Sample 1:
Pickme
imgonnawin!
Tryagainagain
Enter Sample 2:
2 3 5
imgonnawin!
Pickme
Output Sample 2:
Keep going ...
There is only one case in which this question has been won: S>m. This problem to solve the core problem is to go to heavy, there is no good way, I was every input a winner on the check is not won, won the separate record of award, did not win the jump. The code is as follows:
 #include <stdio.h> #include <string.h> struct name {char c[21];
NAME[1001];
    int main (void) {int m,n,s;
    int i,j,s1=0;
    Char b[21];
    scanf ("%d%d%d", &m,&n,&s);
        if (s>m) {for (i=0;i<m;i++) gets (b);
    printf ("Keep going...\n");
            else {for (i=0;i<m;i++) {gets (b);
                    if (((++s1-s)%n==0&&s1>=s)) {for (j=0;j<i;j++) {
                    if (strcmp (name[j].c,b) ==0) {s1--;break;
                    } if (j==i) {strcpy (name[i].c,b);
                printf ("%s\n", b);
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.