TCO '09 elimination round 2 planefractal Recursion

Source: Internet
Author: User

question link: http://www.topcoder.com/stat? C = problem_statement & PM = 10333

// The overall idea of recursion is macroscopic. <br/> # include <string> <br/> # include <vector> <br/> # include <cmath> <br/> using namespace STD; <br/> struct planefractal <br/> {<br/> char check (int s, int N, int K, int X, int y) <br/>{< br/> If (S = 0) <br/> return '0'; <br/> long center = POW (n, s-1 ); <br/> long nn = N * center; <br/> long KK = K * center; <br/> If (x> = (NN-KK) /2 & x <(NN-KK)/2 + KK) & Y> = (NN-KK)/2 & Y <(NN-KK)/2 + KK )) <br/> return '1'; <br/> return check (S-1, N, K, X % center, Y % center ); <br/>}< br/> vector <string> getpattern (int s, int N, int K, int R1, int R2, int C1, int C2) <br/>{< br/> vector <string> ans (r2-r1 + 1, string (c2-c1 + 1 ,'')); <br/> for (INT I = 0; I <= r2-r1; I ++) <br/> {<br/> for (Int J = 0; j <= c2-c1; j ++) <br/> {<br/> ans [I] [J] = check (S, N, K, I + R1, J + C1); <br/>}< br/> return ans; <br/>}< br/> }; 

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.