Baekjoon 1074
Z


QUESTION ❔



CODE ⌨️

#include <iostream>
#include <cmath>

using namespace std;

int N, r, c;
int cnt = 0;

void function(int x, int y, int Size)
{
	if (x == r && y == c)
	{
		cout << cnt << "\n";
		return;
	}

	if (r < x + Size && x <= r && c < y + Size && y <= c)
	{
		function(x, y, Size / 2);
		function(x, y + Size / 2, Size / 2);
		function(x + Size / 2, y, Size / 2);
		function(x + Size / 2, y + Size / 2, Size / 2);
	}
	else
	{
		cnt += (int)pow(Size, 2);
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> N >> r >> c;

	function(0, 0, (int)pow(2, N));

	return 0;
}



RESULT 💛



SIMPLE DISCUSSION ✏️

재귀의 문제였으며, 이 문제에서 많은 아이디어(ex. 데이터 전처리)를 공부할 수 있었다.



SOURCE 💎

Baekjoon_Link 👈 Click here


*****
NOT A TALENT ❎ NOT GIVING UP ✅
CopyRight ⓒ 2022 DCherish All Rights Reserved.