Exemple #1
0
int main(){
	//read input
	{
		scanf("%d %d %d",&n,&m,&k);
		int k_i;
		equation = (char **)malloc(sizeof(long long)*k);
		for( k_i = 0 ; k_i < k ; k_i++ ){
			equation[k_i] = (char *)malloc(sizeof(char)*256);
			scanf("%s",equation[k_i]);
		}
	}

	//compute all case:a
	long long a = 1;
	{
		int m_i;
		for( m_i = n ; m_i > n-m ; m_i-- ){
			a *= m_i;
		}
	}

	//computing
	int s = 0;
	long long a_i,a_j = -100;
	for( a_i = 0 ; a_i < a ; a_i++ ){
		//generate varibles
		if( a_j == a_i-1 ){
			generate_next(a_i);
		}
		else{
			generate_varibles(a_i);
		}
		a_j = a_i;

		//check & record
		//print_equation();
		if( check_equation() ){//1:if right answer,0:if wrong answer
			s++;
		}

	}

	printf("%d",s);

	return 0;
}
Move MovePicker::next_move<false>() {

  Move move;

  while (true)
  {
      while (cur == end)
          generate_next();

      switch (phase) {

      case MAIN_SEARCH: case EVASION: case QSEARCH_0: case QSEARCH_1: case PROBCUT:
          cur++;
          return ttMove;

      case CAPTURES_S1:
          move = pick_best(cur++, end)->move;
          if (move != ttMove)
          {
              assert(captureThreshold <= 0); // Otherwise we cannot use see_sign()

              if (pos.see_sign(move) >= captureThreshold)
                  return move;

              // Losing capture, move it to the tail of the array
              (endBadCaptures--)->move = move;
          }
          break;

      case KILLERS_S1:
          move = (cur++)->move;
          if (    move != MOVE_NONE
              &&  pos.is_pseudo_legal(move)
              &&  move != ttMove
              && !pos.is_capture(move))
              return move;
          break;

      case QUIETS_1_S1: case QUIETS_2_S1:
          move = (cur++)->move;
          if (   move != ttMove
              && move != killers[0].move
              && move != killers[1].move)
              return move;
          break;

      case BAD_CAPTURES_S1:
          return (cur--)->move;

      case EVASIONS_S2: case CAPTURES_S3: case CAPTURES_S4:
          move = pick_best(cur++, end)->move;
          if (move != ttMove)
              return move;
          break;

      case CAPTURES_S5:
           move = pick_best(cur++, end)->move;
           if (move != ttMove && pos.see(move) > captureThreshold)
               return move;
           break;

      case CAPTURES_S6:
          move = pick_best(cur++, end)->move;
          if (to_sq(move) == recaptureSquare)
              return move;
          break;

      case QUIET_CHECKS_S3:
          move = (cur++)->move;
          if (move != ttMove)
              return move;
          break;

      case STOP:
          return MOVE_NONE;

      default:
          assert(false);
      }
  }
}