-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1074.js
47 lines (37 loc) · 887 Bytes
/
1074.js
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
var readline = require("readline");
var r = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let input = [];
r.on("line", function (line) {
input.push(line);
}).on("close", function () {
main(input);
process.exit();
});
let result = 0
function Z(length, x, y) {
const flag = length / 2;
console.log(result)
if (length === 1) return;
if (x < flag && y < flag) {
Z(flag, x, y)
}
else if (x >= flag && y < flag) {
result += (flag * flag);
Z(flag, x - flag, y)
}
else if (x < flag && y >= flag) {
result += (flag * flag) * 2
Z(flag, x, y - flag)
}else{
result += (flag * flag) * 3
Z(flag, x - flag, y - flag)
}
}
function main(input) {
const [N, r, c] = input[0].split(" ").map(Number);
Z(2 ** N, c, r);
console.log(result)
}