Fossil Excavation Event
Time limit0.5sMemory limit1024 MB
Count grid cells (x,y) in [-n,n]^2 where max(|x|,|y|) differs from max(|x|,|y-k|), for n,k up to 1e9.
- Level
Medium7 of 10
- Topics
- Math, Geometry, Implementation, Brute force
- Solved
- No attempts yet
Problem

[Figure] The field with ,
To mark the opening of the Yonsei University freshman programming contest, Gukryeol planned to hold a fossil excavation event at the field near the engineering building. The fossil excavation event is an event where participants find fossils buried in the field near the engineering building. However, an experiment inside the engineering building contaminated part of the field with a substance that is extremely dangerous to the human body.
Because of this, Gukryeol postponed the fossil excavation event and decided to carry the uncontaminated soil from the field to another place before holding the event. Since he planned to hire an outside company for this work, he had to know the cost of moving the soil in advance, and to compute it he needed the number of cells that contain uncontaminated soil.
The field is a grid of , where the bottom-left cell is and the top-right cell is . If some , satisfy , then the soil at is uncontaminated clean soil; otherwise it is contaminated soil. For example, if the field is given as , as in the [Figure], the number of cells that contain uncontaminated soil is 6 in total.
Given and , find the number of cells that contain uncontaminated soil.
Input
The first line gives and . ()
Output
Print the number of cells that contain uncontaminated soil.