Fraises dans une boîte
시간 제한4초메모리 제한1024 MB
이진 격자에 딸기를 최소한으로 추가해 모든 1 칸이 서로 다른 (행 누적, 열 누적) 쌍을 갖도록 만든다.
문제
A box is divided into grids with rows and columns. Some squares contain strawberries.
The state of the box is denoted by , and means that the square in the -th row and -th column contains one strawberry. If , the square in the -th row and -th column is empty.
Tomoe devised the following method to distinguish between these strawberries.
- Let be defined as the sum of for all integer pairs satisfying , .
- Let be defined as the sum of for all integer pairs satisfying , .
- If the square in the -th row and -th column contains a strawberry, label the strawberry with the tuple .
This method could result in multiple strawberries having the same label, and the strawberries could not be distinguished. Therefore, she decided to add some strawberries before labeling them.
More formally, for such that , we operated any number of times greater than .
What is the minimum number of strawberries that must be added to label all the strawberries differently?
입력
출력
Output the answer in one line. Add a new line at the end of the output.
제한
- All inputs consist of integers.
힌트
In Sample Input 1, Tomoe can achieve the condition by placing a strawberry in the upper right square.