## 441 - Lotto PE

Moderator: Board moderators

### 441 - Lotto PE

Any trick in getting AC instead of PE on this problem 441 (Lotto)? I tried couple newline variations but still no luck.
stcheung
Experienced poster

Posts: 114
Joined: Mon Nov 18, 2002 6:48 am

### 441

Between every output set you should put a new line.
Remember
The test cases have to be separated from each other by exactly one blank line. Do not put a blank line after the last test case.

Also exactly one space between integers sholud be followed.

See the sample ouput for input
Code: Select all
`7 1 2 3 4 5 6 77 1 2 3 4 5 6 70`

Output
Code: Select all
`1 2 3 4 5 6\n1 2 3 4 5 7\n1 2 3 4 6 7\n1 2 3 5 6 7\n1 2 4 5 6 7\n1 3 4 5 6 7\n2 3 4 5 6 7\n\n1 2 3 4 5 6\n1 2 3 4 5 7\n1 2 3 4 6 7\n1 2 3 5 6 7\n1 2 4 5 6 7\n1 3 4 5 6 7\n2 3 4 5 6 7\n`

If same you owe an AC.
Solving for fun..

linux
Learning poster

Posts: 56
Joined: Sat Jul 01, 2006 12:21 pm

Thanks a lot Mr Linux

this is really a fishi problem.
keep postin.

newton
Experienced poster

Posts: 162
Joined: Thu Jul 13, 2006 7:07 am

### Re: 441 - Lotto PE

Code: Select all
`Yes!!!I got Accepted i was taking the input in wrong wayAgain thank you very much linux`
try_try_try_try_&&&_try@try.com
This may be the address of success.
Obaida
A great helper

Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 441 - Lotto PE

Hi,
Sorry for reviving an old thread,but I am not sure why am i getting WA:
Code: Select all
`#include<stdio.h>int main(){int i,j,size,a[49],b[6],l,k,m,n;while(1)    {    scanf("%d",&size);    if(size==0)        break;    for(i=0;i<size;i++)     {    scanf("%d",&a[i]);    if(i<6)      b[i]=a[i];    }        j=4;    l=5;    n=l+1;    m=size;        for(i=0;i<6;i++)       printf("%d ",b[i]);       while(j>=(-1))   {    if(l>j)   {   if(n<m)      {      b[l]=a[n];       printf("\n");       for(i=0;i<6;i++)         printf("%d ",b[i]);       n++;      }       else       {        n=l+1;       l--;       m--;       }   }    else         {         k=0;          for(i=0;i<7;i++)           {           if(i==j)            continue;           b[k]=a[i];           k++;          }        n=i;         if(j>=0)          {          printf("\n");        for(i=0;i<6;i++)            printf("%d ",b[i]);         }          j--;         m=size;         l=5;      }      }printf("\n");}return 0;}`

THX.
aaa111
New poster

Posts: 14
Joined: Sat Nov 21, 2009 2:55 pm

### Re: 441 - Lotto PE

Two things i can say:

1.you code does not follow this-

The test cases have to be separated from each other by exactly one blank line. Do not put a blank line after the last test case.

2. This print a space after the last number,which should no be.

Code: Select all
`  printf("%d ",b[i]);`
Experienced poster

Posts: 136
Joined: Sat Nov 29, 2008 8:01 am

### Re: 441 - Lotto PE

I have modified the code as what u have said,still no luck:
Code: Select all
`#include<stdio.h>int main(){int i,j,size,a[49],b[6],l,k,m,n,c=0;while(1)    {    if(c==1)     printf("\n");    scanf("%d",&size);    if(size==0)   break;    for(i=0;i<size;i++)    {    scanf("%d",&a[i]);    if(i<6)      b[i]=a[i];     }    c=1;    j=4;    l=5;    n=l+1;    m=size;    for(i=0;i<6;i++)       {       printf("%d",b[i]);       if(i<5)           printf(" ");                 else            printf("\n");          }        while(j>=(-1))   {   if(l>j)     {     if(n<m)       {       b[l]=a[n];              for(i=0;i<6;i++)         {          printf("%d",b[i]);          if(i<5)           printf(" ");                    else          printf("\n");            }       n++;       }     else       {       n=l+1;       l--;       m--;       }      }       else      {      k=0;      for(i=0;i<7;i++)      {      if(i==j)         continue;      b[k]=a[i];      k++;      }      n=i;      if(j>=0)         {         for(i=0;i<6;i++)            {              printf("%d",b[i]);              if(i<5)                 printf(" ");                        else                 printf("\n");              }        }      j--;      m=size;      l=5;       }    }        }return 0;}`
aaa111
New poster

Posts: 14
Joined: Sat Nov 21, 2009 2:55 pm

### Re: 441 - Plz help me.....

I tried 10 more test data and it was all right. But Bad OJ(Sorry ) says it's WA
I don't no why it is
Or hint from code.

Sorry, But I'm using C++.
Code: Select all
`#include <iostream>using namespace std;int s[13];int Base2[13];int main(){   int   k;   int i, j;   int ktimes2;   int cnt = 0;   int imsi;   int cntzero = 0;   int first = false;   while (cin >> k){      if (k == 0) break;      if (first) cout << endl;      first = true;      for (i = 0; i < k; i++){         cin >> s[i];      }            ktimes2 = 1;      for (i = 0; i < k; i++){         ktimes2 *= 2;      }      for (i = 0; i < ktimes2; i++){         imsi = i;         for (j = 0; j < 13; j++){            Base2[j] = 0;         }         cnt = 0;         while (imsi > 0){            Base2[cnt++] = imsi%2;            imsi /= 2;         }         cntzero = 0;         for (j = 0; j < k; j++){            if (Base2[j] == 1) cntzero++;         }         if (cntzero == 6){            for (j = 0; j < k; j++){               if (Base2[j] == 1){                  if (j != k-1){                     cout << s[j] << " ";                  }                  else cout << s[j];               }            }            cout << endl;         }      }   }   return 0;}`
mintae71
New poster

Posts: 18
Joined: Tue Jan 19, 2010 10:50 am

### Re: 441 - Lotto PE

it's a very easy problem if your approach is iterative backtracking.
since you need to take a fixed(6) numbers at a time, you can iterate 6 loops. and the limit of k is 6<k<13, so no possibility of getting tle!!
mostafiz93
New poster

Posts: 31
Joined: Thu Nov 24, 2011 12:08 am