Home > Back-end >  An algorithm!
An algorithm!

Time:10-02

It is good to give ideas, thank you!

CodePudding user response:

Procession into the grid, the area of 2 x2 area is 3 x3 grid, and then selected in the grid points, it's up and down or so, upper left, lower left, upper right said it can access to the region at the lower right (as in the center of the case, can visit them in all directions, access to areas most), and traverse the entire grid, found in the grid points can access to the areas most, and points to a minimum,

CodePudding user response:

The problem is the NXM rectangle cover, with 2 x2 rectangular at least how many pieces of

CodePudding user response:

refer to the second floor early play big play nuclear response:
the problem is the NXM rectangle cover, with 2 x2 rectangular at least how many pieces of

Positive solution to the second floor, attach your own code for reference

#include
using namespace std;

Void fun (int n, int m)
{
Int a1, a2=0, a3=0;

A1=(n/2) * (m/2);

If (n % 2)
A2=(m + 1)/2;

If (m % 2)
A3=(n + 1)/2;

If (a2 & amp; & A3)
A2 -;

Cout & lt; }

Int main ()
{
Int n, m;
cin> N & gt;> M;
Fun (n, m);
system("pause");
return 0;
}

CodePudding user response:

reference m0_44977681 reply: 3/f
Quote: refer to the second floor early play big play nuclear war reply:
the problem is the NXM rectangle cover, with 2 x2 rectangular at least how many pieces of

Positive solution to the second floor, attach your own code for reference

#include
using namespace std;

Void fun (int n, int m)
{
Int a1, a2=0, a3=0;

A1=(n/2) * (m/2);

If (n % 2)
A2=(m + 1)/2;

If (m % 2)
A3=(n + 1)/2;

If (a2 & amp; & A3)
A2 -;

Cout & lt; }

Int main ()
{
Int n, m;
cin> N & gt;> m;
Fun (n, m);
system("pause");
return 0;
}

Int main ()
{
Int n, m;
cin> N & gt;> m;
If (n % 2)
N++;
If (m % 2)
M++;
Cout & lt; <(n/2) * (m/2) & lt; system("pause");
return 0;
}

CodePudding user response:

M0_44977681
reference 4 floor response:
Quote: refer to the third floor m0_44977681 response:
Quote: refer to the second floor play big shoot early nuclear response:
the problem is the NXM rectangle cover, with 2 x2 rectangular at least how many pieces of

Positive solution to the second floor, attach your own code for reference

#include
using namespace std;

Void fun (int n, int m)
{
Int a1, a2=0, a3=0;

A1=(n/2) * (m/2);

If (n % 2)
A2=(m + 1)/2;

If (m % 2)
A3=(n + 1)/2;

If (a2 & amp; & A3)
A2 -;

Cout & lt; }

Int main ()
{
Int n, m;
cin> N & gt;> m;
Fun (n, m);
system("pause");
return 0;
}

Int main ()
{
Int n, m;
cin> N & gt;> m;
If (n % 2)
N++;
If (m % 2)
M++;
Cout & lt; <(n/2) * (m/2) & lt; system("pause");
return 0;
}

Only the main function is ok?

CodePudding user response:

reference 5 floor MJlucy reply:
Quote: refer to 4th floor m0_44977681 response:
Quote: refer to the third floor m0_44977681 response:
Quote: refer to the second floor early play big play nuclear war reply:
the problem is the NXM rectangle cover, with 2 x2 rectangular at least how many pieces of

Positive solution to the second floor, attach your own code for reference

#include
using namespace std;

Void fun (int n, int m)
{
Int a1, a2=0, a3=0;

A1=(n/2) * (m/2);

If (n % 2)
A2=(m + 1)/2;

If (m % 2)
A3=(n + 1)/2;

If (a2 & amp; & A3)
A2 -;

Cout & lt; }

Int main ()
{
Int n, m;
cin> N & gt;> m;
Fun (n, m);
system("pause");
return 0;
}

Int main ()
{
Int n, m;
cin> N & gt;> m;
If (n % 2)
N++;
If (m % 2)
M++;
Cout & lt; <(n/2) * (m/2) & lt; system("pause");
return 0;
}

Only the main function is ok?

Yes, that is above my head did not turn around, write very complex, the idea of really strong, on the second floor in the main function,
As if the original area the number of rows and columns is not even, add 1 to fill it into an even number, and then in 2 x2 rectangle filling line

CodePudding user response:

refer to 6th floor m0_44977681 response:
Quote: refer to the 5 floor MJlucy response:
Quote: refer to 4th floor m0_44977681 response:
Quote: refer to the third floor m0_44977681 response:
Quote: refer to the second floor early play big play nuclear war reply:
the problem is the NXM rectangle cover, with 2 x2 rectangular at least how many pieces of

Positive solution to the second floor, attach your own code for reference

#include
using namespace std;

Void fun (int n, int m)
{
Int a1, a2=0, a3=0;

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related