I Want to Go to DIMIGO!
Time limit1sMemory limit1024 MB
Given a page range from A to B, find the fewest photos, where one photo can capture a single page or an open spread of pages 2k-1 and 2k.
- Level
Easy2 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
ecode attended an admissions briefing because ecode wanted to go to DIMIGO. Wanting to learn more about the school, ecode received a booklet with information about it.
Each sheet of the booklet has two pages. When a spread is open, the left side is the odd-numbered page and the right side is the even-numbered page.
ecode wants to photograph the contents from page to page of this booklet. Photographing every page one by one is tedious, so when all the pages to be saved fit on one open spread, ecode tilts the phone sideways and captures that part at once.
The image below shows the best way to capture pages 4 to 6.

Tilting the phone vertically to photograph page 4 alone, then tilting it horizontally to capture pages 5 and 6 together, saves the desired pages in 2 shots.
Find the minimum number of photos needed to save every page from page to page .
Input
The first line contains two integers and , the first and last page to photograph, separated by a space.
Output
Print the minimum number of photos needed to save every page from page to page .
Hint
The booklet is thick, with up to pages, because the school has so many advantages to explain. It could have been much longer, but for the reader's sake it was summarized heavily.