프로그램 명: coci_cvenk
제한시간: 3 초

A group of Czech tourists is walking in a labyrinth of a strange self-similar shape. The ground plan of the labyrinth is a Sierpinski triangle - a fractal structure named after the Polish mathematician Waclaw Sierpiski.

The labyrinth consists of a billion rows numbered from 0 to 10^9-1 from top to bottom, and a billion columns numbered from 0 to 10^9 - 1 from left to right. The fields in the labyrinth can be either free or blocked. The field in row X and column Y is free if the result of the bitwise ‘and’ operation on the numbers X and Y is equal to zero, otherwise it is blocked. In other words, a field is blocked if, when X and Y are switched to binary, there is an integer k such that the k-th digit from the right of the number X and the k-th digit from the right of the number Y are equal to 1.

The Czech tourists are tired from a long day of wandering and would like to meet up in a free field and exchange experiences. In each step, one tourist can jump to one of the adjacent free fields (up, down, left or right).

Write a programme that will, based on the current tourists’ locations, determine minimum total number of steps necessary in order for all the tourists to meet in the same field.

입력

출력

The first and only line of output must contain the required minimum number of steps.

Please note: We recommend that you use a 64-bit integer data type (int64 in Pascal, long long in C/C++).

입출력 예

입력

2
2 1
4 3

출력

6 

입력

6
2 5
3 4
8 7
9 6
10 5
11 4

출력

50

Clarification of the first example: One of the fields where the brave Czech tourists could have met is
(2, 0).

Clarification of the second example: One of the fields where the playful Czech tourists could have met
is (8, 4).
출처:2013-2014 olympiad 1/4

[질/답] [제출 현황] [푼 후(0)]
[ 채 점 ] [홈으로]  [뒤 로]