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
Solve for x <br><br> -7(1-8x)=105
Sunny_sXe [5.5K]
-7 + 56x = 105
56x = 105 + 7
56x = 112
x = 2
4 0
3 years ago
Which is the best estimate for the area of the figure above?
nekit [7.7K]

Answer:

So I'd say 20in^2 or 22in^2.

Step-by-step explanation:

I decided to make it into a full pentagon shape to just estimate.

So a pentagons sides are all equal so I counted the amount in boxes on the sides of the regular shape and most of them would be 3.5 if you changed the shape into a pentagon.

And I got:

--> 21.076

5 0
3 years ago
Read 2 more answers
Which statement correctly describes the expression (-60)(-5)?
Elina [12.6K]
It would be b. If two numbers are negative and your multiplying them, it would be positive!
8 0
3 years ago
Read 2 more answers
What is 4.583.269 rounded to the nearest hundredth
Ede4ka [16]

4,583.27 is 4,583.269 rounded to the nearest hundredth



3 0
3 years ago
Adrian earns $3600 per month. he spends 1/4 of his income on rent, 2/5 on food, 1/9 on activities, and he saves the rest. how mu
murzikaleks [220]

he saves $860 per month

calculate each of his outgoings

rent = \frac{1}{4} × $3600 = \frac{3600}{4} = $900

food = \frac{2}{5} × $3600 = \frac{2(3600)}{5} = $1440

activities = \frac{1}{9} × $3600 = \frac{3600}{9} = $400

savings = $3600 - ( 900 + 1440 + 400 ) = $860


4 0
3 years ago
Read 2 more answers
Other questions:
  • Between the 2010 US census and 2015, the estimated pulation of El paso, Texas, increased from aproximately 649,000 to 681,000. D
    9·1 answer
  • What is 64x64? and I know if you use a calculator =)
    13·1 answer
  • What are the pattern for the following numbers, 27, 18, 12, 8?
    11·2 answers
  • What are three fields scientific notation is used in
    14·1 answer
  • The coordinate grid shows three points P, Q, and R:
    11·2 answers
  • A grocery store chain has $409,384 to buy watermelons. If each watermelon costs $4, how
    11·1 answer
  • A right rectangular prism has a volume of
    10·1 answer
  • Write the given polynomial in standard form and write its degree .
    9·2 answers
  • If 4 people ate at a restaurant. If each person paid an equal amount who would save the most money
    8·2 answers
  • Activity 4: Direction: Given below are examples of how to simplify radicals. Identify if the given process below is TRUE or FALS
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!