1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Yanka [14]
3 years ago
13

6 Knightmare Give an algorithm to find the number of ways you can place knights on an N by M (M < N) chessboard such that no

two knights can attack each other (there can be any number of knights on the board, including zero knights). Clearly describe your algorithm and prove its correctness.
Mathematics
1 answer:
JulsSmile [24]3 years ago
7 0

Answer:

Function to return the maximum number of  knights that can be placed on the given chessboard such that no two knights attack each other.

Step-by-step explanation:

In this algorithm it's fully described the maximum number

#include <bits/stdc++.h>  

using namespace std;  

 

int max_knight(int n, int m)  

{  

 

  // Check for corner case #1  

   //If row or column is 1

   if (m == 1 || n == 1) {  

 

       // If yes, then simply print total blocks  

       // which will be the max of row or column  

       return max(m, n);  

   }  

 

   // Check for corner case #2  

   // If row or column is 2  

   else if (m == 2 || n == 2) {  

 

       // If yes, then simply calculate  

       // consecutive 2 rows or columns

       int c = 0;  

       c = (max(m, n) / 4) * 4;  

 

       if (max(m, n) % 4 == 1) {  

           c += 2;  

       }  

       else if (max(m, n) % 4 > 1) {  

           c += 4;  

       }  

       return c;  

   }  

 

  // For general case, just print the  

   // half of total blocks

   else {  

       return (((m * n) + 1) / 2);  

   }  

}  

 

// Driver code  

int main()  

{  

   int n = 4, m = 5;  

 

   cout << max_knight(n, m);  

 

   return 0;  

}

You might be interested in
Two over five, one over four, three over eight
jek_recluse [69]

Answer:

I would like to solve your problem but plz comment the equation

Step-by-step explanation:

2/5×1/4×3/8 is 6/160

7 0
3 years ago
Read 2 more answers
Two sides of a triangle measure 9 cm and 23 cm what could be the measurement of the third side of the triangle
Vladimir79 [104]
Pythagorean Theorem: a^2+b^2=c^2
(9)^2 + b^2 = (23)^2
81 + b^2 = 529
b^2 = 529 - 81
b^2 = 448
b^2 =
\sqrt{448}
b = 21.2
6 0
3 years ago
Which equation matches the graph?
Iteru [2.4K]

Answer:

D

Step-by-step explanation:

intercept is -4 and slope is rise over run which is 3/1 = 3

put into slope intercept form to achieve answer D

7 0
3 years ago
Read 2 more answers
(01.05 MC)
Dennis_Churaev [7]

Answer:

least to greatest : 14/9 , sqrt 7, sqrt 13, sqrt 40, 4^3

Step-by-step explanation:

7 0
3 years ago
When an octave is divided into twelve equal steps, a chromatic scale results. The ratios between sucessive notes is
alukav5142 [94]

Answer: They would be A.

Step-by-step explanation: Don't take my word for it 100%

7 0
3 years ago
Other questions:
  • To get to his office from home, Greg walks 6 blocks north and then 3 blocks east. After work he meets some friends at a cafe; to
    7·1 answer
  • On a coordinate grid, the coordinates of vertices P and Q for Polygon PQRS are P(1, 3) and Q(−3, 3). What is the length of Side
    6·2 answers
  • What is 3 3/4 - 1 1/4
    5·2 answers
  • The set of whole numbers is not a subset OF --
    12·1 answer
  • What number gives a result of 1 when 9 is subtracted from the quotient of the number and 4?
    13·1 answer
  • I need help on the part where it says devonte
    5·1 answer
  • As a marketing manager, you are tasked with selecting a website to place your advertisement. The following sampled data shows th
    9·1 answer
  • PLEASE ANSWER fast <br><br><br>-2/9(-5/3)=
    5·1 answer
  • Find the equation of the quadratic function with vertex (-2,18) passing through (-5,0)?
    14·1 answer
  • If Dominik completes a project by himself, it will take him 8 hours. Working with Katarina, it will take them 5 hours.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!