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
A cylinder has a radius of 4.5 inches and a height of 10 inches. What is the
nata0808 [166]

Answer:

B.

Step-by-step explanation:

5 0
2 years ago
What is the solution to the following system?
iogann1982 [59]

9514 1404 393

Answer:

  4.  (4, 5)

Step-by-step explanation:

Use substitution to put the value for y in the second equation.

  -3x +4(5) = 8

  -3x = -12 . . . . . . . subtract 20

  x = 4 . . . . . . . . . . divide by -3

The solution is (x, y) = (4, 5).

3 0
3 years ago
Evaluate sin 45° cos 60° + tan 45°
Anna [14]

Answer:

√2/4 + 1

Step-by-step explanation:

sin 45° --> √2/2

cos 60° --> 1/2

tan 45° --> 1

with these values, we write a new expression

√2/2 × 1/2 + 1

√2/2 × 1/2 = √2/4

(by doubling the denominator, you are splitting the number in half as implied by the 1/2)

your answer is √2/4 + 1

goodluck :)

7 0
3 years ago
What is a mixed radical in simplest form? Use square root number 72.
puteri [66]
It is 8 because you would do 9x8=72
7 0
3 years ago
Two questions in one.
s2008m [1.1K]
Question 1: 4.375/10 of an hour (or 26.25 minutes)
4 0
3 years ago
Other questions:
  • Michaela drove south for 4 hours and went 260 miles. What was Michaela's velocity?
    7·1 answer
  • What is 3x + 2y + 5 - 3
    6·2 answers
  • Find the fraction that is equivalent to 21%
    15·2 answers
  • N/6=9/3? i dont what this is can someone please help me!!!!
    12·2 answers
  • Five added to 4 times a number is equal to 9 less than 2 times the number
    8·1 answer
  • Which one is the right graph
    11·1 answer
  • Angle A corresponds to Angle<br> OB<br> Oc<br> ОЕ<br> OD<br> none of the above
    9·1 answer
  • Members of a baseball team raised $1781.25 to go to a tournament. They
    15·1 answer
  • Adrienne and Suki simplified the expression –8 – (–6). Whose answer is correct? Explain where the error was made.
    15·1 answer
  • Which rule explains why these triangles are congruent?
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!