441 - Lotto PE

All about problems in Volume IV. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

441 - Lotto PE

Postby stcheung » Wed Feb 21, 2007 8:48 am

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

Postby linux » Mon Jul 16, 2007 12:44 pm

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 7
7 1 2 3 4 5 6 7
0


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


If same you owe an AC. :D
Solving for fun..
User avatar
linux
Learning poster
 
Posts: 56
Joined: Sat Jul 01, 2006 12:21 pm
Location: Dhaka (CSE, DU), Bangladesh

Postby newton » Sun Mar 16, 2008 9:53 pm

Thanks a lot Mr Linux

this is really a fishi problem.
keep postin.
User avatar
newton
Experienced poster
 
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh

Re: 441 - Lotto PE

Postby Obaida » Tue Jul 29, 2008 9:32 am

I got WA again and again. :( Some one please help me.
Code: Select all
Yes!!!
I got Accepted i was taking the input in wrong way
Again 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
Location: (BUBT) Dhaka,Bagladesh.

Re: 441 - Lotto PE

Postby aaa111 » Fri Aug 27, 2010 8:19 pm

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

Postby sazzadcsedu » Sat Aug 28, 2010 1:28 pm

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]);
sazzadcsedu
Experienced poster
 
Posts: 136
Joined: Sat Nov 29, 2008 8:01 am
Location: narayangong,bangladesh.

Re: 441 - Lotto PE

Postby aaa111 » Sat Aug 28, 2010 4:05 pm

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.....

Postby mintae71 » Wed Sep 08, 2010 12:53 pm

I tried 10 more test data and it was all right. But Bad OJ(Sorry :roll: :roll: :roll: :roll: :roll: :roll: :roll: ) says it's WA
I don't no why it is :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry:
Please help me.....
Please give some critical inputs......
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

Postby mostafiz93 » Thu Apr 19, 2012 2:30 pm

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


Return to Volume IV

Who is online

Users browsing this forum: Bing [Bot] and 1 guest