algorithm'''problem solve
[백준] 1074 - Z(설명X)
JunHwa Park
2020. 4. 18. 23:50
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <iostream> using namespace std; int main() { int N, r, c, x = 0, y = 0, index = 0; cin >> N >> r >> c; int num = 1; for (int i = 1; i < N; i++) num *= 2; while (num > 0) { if (r >= y + num) { y += num; index += num * num * 2; } if (c >= x + num) { x += num; index += num * num; } num /= 2; } cout << index << endl; } | cs |