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
Given that the sum of the measures of the interior angles of a triangle is 180°, find the measure of each interior angle of a re
VikaD [51]
90 Degree Or 45 Degree Not really sure But I would really choose not 90degree
5 0
3 years ago
What is 25 divided by its square root? Brainliest for best answer.
uysha [10]

Answer:

5

Step-by-step explanation:

Because the square root of 25 is 5 so then do 25 divided by 5 to get 5 as your awnser.

5 0
3 years ago
Read 2 more answers
(I can mark the first correct person brainliest!)
Mashutka [201]
35 which is slope which in turn represents the speed.
6 0
3 years ago
4 cents per day equals blank dollars per day
Oksana_A [137]
.04 dollars per day is what it eqqualz
3 0
3 years ago
Y
Schach [20]

Answer:

step 1:

2,-5

step 2:

7,1

step 3:

6/5

Step-by-step explanation:

5 0
3 years ago
Other questions:
  • If the relative frequencies are 0.48 and 0.52, which conclusion is most likely supported by the data?
    6·2 answers
  • Look at the photo I need help pleasse
    15·1 answer
  • PLEASE HELP!!! Does this table represent a function? Why or why not?
    7·1 answer
  • A. Find the value of a. b. Find the value of the marked angles.
    14·2 answers
  • Here's a list of numbers : 13, 27 ,81, 21 ,43, 48 ,23, 39 ,45 From this list, write down a.) The even number b.) The square numb
    10·2 answers
  • A man bought a car for $8,200 and sold it for 80% of the price two years later. How much did he lose?
    11·2 answers
  • Which one would be correct
    10·1 answer
  • Huilan is 15 years younger than Thomas. The sum of their ages is 33 . What is Thomas's age?
    8·1 answer
  • Complete the steps to evaluate log798, given log72 ≈ 0.356. how can you rewrite log798 using the product property?
    7·2 answers
  • Can someone figure this out for me?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!