[Excellent reading questions] HDU 1057 -- A New Growth Industry

Source: Internet
Author: User

Source: Click to open the link

A very good simulation question, it looks complex enough. You must understand the meaning of the question, especially the number of days, which is not directly related to the array. It is only related to the number of DNA updates. This is a day... Orz

You can try the simulation.

# Include <iostream> # include <string> # include <cstring> using namespace STD; int dir [4] [2] = {0,-1}, {0, 1 }, {-}, {}; int mat [20] [20], tar [20] [20], tar2 [20] [20]; char transtar [20] [20]; int pxvalue [16]; int main () {int testcase; CIN> testcase; For (int s = 1; S <= testcase; s ++) {memset (MAT, 0, sizeof (MAT); memset (TAR, 0, sizeof (TAR); memset (pxvalue, 0, sizeof (pxvalue); int day, TMP, tmpx, tmpy; CIN> day; for (INT I = 0; I <16; I ++ ){ Cin> pxvalue [I] ;}for (INT I = 0; I <20; I ++) {for (Int J = 0; j <20; j ++) {CIN> mat [I] [J] ;}}for (int K = 0; k <day; k ++) {for (INT I = 0; I <20; I ++) {for (Int J = 0; j <20; j ++) {TMP = mat [I] [J]; for (INT z = 0; Z <4; Z ++) {tmpx = I + dir [Z] [0]; tmpy = J + dir [Z] [1]; if (tmpx> = 0 & tmpx <20 & tmpy> = 0 & tmpy <20) TMP + = mat [tmpx] [tmpy];} tar [I] [J] = mat [I] [J] + pxvalue [TMP]; If (TAR [I] [J]> 3) tar [I] [J] = 3; if (TAR [I] [J] <0) tar [I] [J] = 0 ;}} memcpy (MAT, tar, sizeof (MAT )); // Rolling update, top priority} For (INT I = 0; I <20; I ++) {for (Int J = 0; j <20; j ++) {If (TAR [I] [J] = 0) {transtar [I] [J] = '. ';} else if (TAR [I] [J] = 1) {transtar [I] [J] = '! ';} Else if (TAR [I] [J] = 2) {transtar [I] [J] = 'X ';} else if (TAR [I] [J] = 3) transtar [I] [J] = '#' ;}} for (INT I = 0; I <20; I ++) {for (Int J = 0; j <20; j ++) {cout <transtar [I] [J] ;}cout <Endl ;} if (s! = Testcase) cout <Endl;} return 0 ;}

 

Related Article

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.