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/> };