Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 29th, 2012  |  syntax: C++  |  size: 0.89 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include<cstdio>
  2. #include<cmath>
  3. #include<algorithm>
  4. using namespace std;
  5.  
  6. #define P printf
  7. #define S scanf
  8.  
  9. int kon , ans , array[1050000],tab[20][20],mx;
  10.  
  11. void pro( int k , int round , int sum )
  12. {
  13.     if ( round == ans +1 )
  14.     {
  15.         array[sum]++;
  16.         mx = max (array[sum] , mx);
  17.     }
  18.     else
  19.     {
  20.         if ( tab[k][round] == 1 )   pro ( k , round + 1 , sum + pow ( 2 , round-1));
  21.         else if ( tab[k][round] == -1) pro ( k , round + 1 , sum );
  22.         else
  23.         {
  24.             pro ( k , round + 1 , sum + pow ( 2 , round-1));
  25.             pro ( k , round + 1 , sum );
  26.         }
  27.     }
  28. }
  29.  
  30. int main()
  31. {
  32.     int i,j;
  33.     S("%d%d",&kon,&ans);
  34.     for( i=1 ; i<=kon ; i++ )
  35.     {
  36.         for( j =1 ; j <= ans ; j++ )
  37.         {
  38.             S("%d",&tab[i][j]);
  39.         }
  40.     }
  41.     for( i=1 ; i<=kon ; i++ )   pro ( i , 1 ,0 );
  42.     P("%d",kon - mx);
  43. }