<html>

Source: Internet
Author: User

#include <iostream>using namespace std;/** The main idea of the problem: * 1, average bar this 2 of the K power of the squares divided into 4 parts * 2, a special box containing a part of * 3, There are 3 left without special squares to contribute a small block to synthesize an "L", and then make the small square that you just contributed to as a special square. Again back to step 1*5, assuming that the special box is less than 4 is already all divided, jump out *///we have to know is K row k column square. So there will be K, know the position of the special squares row and column th, TL, the starting position of the new squares after dividing newh,newl, rows and columns void Qipan (int k, int th, int tl, int newh, int newl, int a[]) {//Start cutting chess --------------------------------*/int t=0;//dominoes number int s=k/2;//cut checkerboard//int a[4] = {0};//represents four different L-shaped squares//At the beginning of the division of 4 parts, Special squares can exist in 4 chunks of each block//special squares in the upper left part if (Th < newh+s && tl < newl+s) {//Here special squares are at the top left, call 4th L Domino A[3]+=1;qipan (s, Th, TL, NEWH, NEWL, a);//S: This is the number of rows of the cutting board th: The high tl of special squares: The column of Special Squares NEWH: The starting line of this large square NEWL: The starting column}else{//there is no special squares in the upper left-hand board// So the lower left corner of the square as a part of L block Qipan (S, newh+s-1, Newl+s-1, NEWH, NEWL, a);} ------------------------------------------------------------------------------------//Special squares in the lower left part if (Th > NEWH +s-1 && TL < newl+s) {//Here the special squares are in the upper left., call No. 2nd L Domino a[1]++;qipan (s, Th, TL, newh+s, NEWL, a);//S: This is the number of rows of the cutting board th: special squares of high TL: special squares of columns NEWH: The starting row of this large square NEWL: Start column}else{// There is no special box in the upper left of the chessboard//that the lower left corner of the square as a part of L block Qipan (S, NEWH + S, newl + s-1, Newh+s, NEWL, a);} ------------------------------------------------------------------------------------/* Dominoes can have 4 kinds of-------------------------- ---------* * * * * * * * * * * * * * *------------------------------------*///Special squares on upper right if (Th < newh+s && tl > Newl+s-1) {//Here special squares are at the top left. Just call 3rd L Domino A[2]++;qipan (s, Th, TL, NEWH, Newl+s, a);//S: This is the line of the cutting board th: special squares of high TL: special squares of columns NEWH: The starting row of this large square NEWL: Start column}else{// There is no special box in the upper left of the chessboard//that the lower left corner of the square as a part of L block Qipan (s, Newh + s-1, NEWL + S, NEWH, Newl+s, a);} ------------------------------------------------------------------------------------//Special squares in the lower right part if (Th > NEWH +s-1 && tl > Newl+s-1) {//Here the Special square is at the top left, call 1th L Domino a[0]++;qipan (s, Th, TL, newh+s, NEWL + S, a);//S: This is the number of rows of the cutting board th: Special The high TL: special squares of the column NEWH: The starting line of this large square NEWL: The starting column}else{//the upper left of the board there is no special box//that the lower left corner of the square as a part of L with L block Qipan (s, NEWH +S, Newl + S, newh+s, Newl+s, a);}} /*void Test (int *b) {for (int i = 0; I <= 3; ++i) {b[i]++;if (i = = 2) {B[i] = 998;}}} */int Main () {char C;int a[4] = {0};qipan (4, 1, 2, 1, 1, a);//cout << "Altogether:" << Qipan (4, 1, 2, 1, 1, a) &LT;&L t; " << endl;/* dominoes can have 4 kinds of-----------------------------------* * * * * * * * * * * * * * * * * Char L[4][2][2] =//uses a multidimensional array to represent these L-shaped dominoes {{{' * ', ' * '}, {' * ', '}}, {' * ', ' * '}, {', ' * '}},{{' * ', '}, {' * ', ' * '}},{{', ' * '}, {' * ', ' * '}}};for (int i = 0; i < 4; ++i) {for (int j = 0; j < 2; ++j)//First line of first Domino {for (i NT k = 0; K < 2; ++K)//The case of each line {cout << l[i][j][k];} cout << Endl;} cout << "<< i +1 <<" L-type dominoes are used in the following times: "<< A[i] << Endl;} /*test (a); for (int i = 0; i < 4; ++i) {cout << a[i] << Endl;} */cin >> C;return 0;}

Read the full text of the copyright notice: This article is the original blogger article. Not reproduced without the consent of the blogger. Report
    • Label:
    • Algorithm /
    • q= design &t=blog "target=" _blank "> Design /

    • Q= Board Overlay &t=blog "target=" _blank "> Board overlay /

    • This article has been included in the following column:
0Article comments
Related articles recommended
JS Algorithm: Partition Method-board overlay with code: NEW Document table,td{border:1px solid gray;
  • jrn1012
  • 2015-08-21 17:02
  • 1112
Board Overlay (NYOJ 45) Topic Link:
  • u013207805
  • 2014-04-08 15:47
  • 426
Board coverage issues #include #include#includeusing namespace std;/** Board overlay problem */static int t=0;void chessboard (int ...
  • u011390632
  • 2014-11-13 10:15
  • 724
On the board coverage problem of board cover problem, it is a kind of mathematics problem solved by divide and conquer method.

The general description of the problem is this: as you can see, (this is my copy on the Internet), this is a 4*4-sized chessboard.

For this kind of problem. The size of the chessboard is generally 2 ...

  • wang7807564
  • 2017-06-28 13:59
  • 59
Division and Treatment--board coverage problem--board coverage problem
. There is a 2k?2k2^k*2^k checkered checkerboard. Just one of the squares is black and the others are white. Your task is to cover all white squares with an L-shaped card that includes 3 squares. Black squares cannot be overwritten. And feel free to a white ...
  • q547550831
  • 2016-05-30 21:59
  • 2078
Analysis, design and implementation of checkerboard overlay algorithm (Java) although it is the same as a lot of blogs, the explanation is the board cover solution.

However, many others tend to "prove", which is what I and a lot of readers want to know, not the beginning of the code. Folder 0, description of the problem ... 11. Related Blogs ... 1 ...

  • qq_19648191
  • 2016-01-02 14:05
  • 774
Solving the board cover problem by the method of divide and conquer 1. Description of the problem: Click to open the link 2. Code: #define _crt_secure_no_warnings#include#include#include#include# Include#in ...
  • u014800748
  • 2015-08-18 16:43
  • 863
Design and analysis of computer algorithms the board coverage problem is in a chessboard of 2^k *2^k blocks. A square is different from other squares. Called the square a special square. and called the chessboard a special chessboard. There are four kinds of L-type dominoes as seen in the present. Use these four kinds of dominoes to cover all the squares except the special squares ...
  • hqh45
  • 2014-10-24 22:16
  • 1058
divide and conquer algorithm specific explanation turn: Http://blog.csdn.net/effective_coder/article/details/8697789<span style= "font-size:16
  • Javablogs
  • 2014-05-25 02:38
  • 121
Computer algorithm design and analysis Job 01: Divide-and-conquer method for solving large-number multiplication +l-type Domino's checkerboard overlay problem computer algorithm design and analysis Job 01: Solving the Board coverage problem of large number multiplication +l type dominoes by divide-and-conquer method 1.2.L Domino Board coverage Problem: code implementation: #include #include # Include ...
  • PNAN222
  • 2016-09-16 19:32
  • 604
Cutter_point's Column + Focus
Original
433
Fans
the
Like
0
    • "Apue" 8, pthread_create function, creating child threads
    • "Apue" 7, Signal function
    • "Apue" 6, orphan process Group
    • "Apue" 5, fork function
many other articles Online Courses

Utm_source=blog7 "target=" _blank ">

"Live" machine learning & Data Mining 7 weeks training--Wei Chi

Utm_source=blog7 "target=" _blank ">

"Package" System integration projects management project Manager smooth clearance--Xu Bong
  • folder
  • like to cancel like
  • Collection
  • share Weibo QQ
Collection Assistant Bad news report

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.