일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- ROP
- 브루트 포스
- RTL
- syscall
- 큐
- off by one
- 백트래킹
- 수학
- 연결리스트
- DFS
- tcache
- heap
- 완전 탐색
- 에라토스테네스의 체
- 동적 계획법
- 분할 정복
- 스위핑 알고리즘
- OOB
- 다이나믹 프로그래밍
- 이분 탐색
- 스택
- 문자열 처리
- BOF
- BFS
- 이진트리
- 이진 탐색
- House of Orange
- fsb
- 포맷스트링버그
- 투 포인터
Archives
- Today
- Total
SDJ( 수돈재 아님 ㅎ )
[C++] 1074 - Z 본문
문제 링크 : https://www.acmicpc.net/problem/1074
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#include<iostream>
#include<algorithm>
#include<math.h>
#define endl '\n'
using namespace std;
int N,r,c;
long long int cnt;
void z(int y, int x, int l)
{
// cout << "[*] " << y << ' ' << x << ' '<< l << ' ' << cnt << endl;
if(y == r && x == c)
{
cout << cnt << endl;
return;
}
if(l >= 2)
{
if(r < y + l/2 && c < x + l/2)
{
z(y + 0, x + 0, l/2);
}
else if(r < y + l/2 && c >= x + l/2)
{
cnt += (l/2)*(l/2);
z(y + 0, x + l/2, l/2);
}
else if(r >= y + l/2 && c < x + l/2)
{
cnt += 2*(l/2)*(l/2);
z(y + l/2, x + 0, l/2);
}
else if(r >= y + l/2 && c >= x + l/2)
{
cnt += 3*(l/2)*(l/2);
z(y + l/2, x + l/2, l/2);
}
}
}
int main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> N >> r >> c;
z(0, 0, pow(2, N));
return 0;
}
|
'알고리즘 > Backjoon' 카테고리의 다른 글
[C++] 17011 - Cold Compress (0) | 2020.01.09 |
---|---|
[C++] 2659 - 십자카드 문제 (0) | 2020.01.09 |
[C++] 1987 - 알파벳 (0) | 2020.01.07 |
[Python3] 2661 - 좋은수열 (0) | 2020.01.07 |
[Python3] 3009 - 네 번째 점 (0) | 2020.01.07 |
Comments