We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Drawing Book
- Discussions
Drawing Book
Drawing Book
Sort by
recency
|
219 Discussions
|
Please Login in order to post a comment
My math skill sucks pants, java brute force approach for fun
Scala
short c++ solution. the main idea is that we can calculate how many pages to turn to get number 'x' by turning 'x//2' pages (divide with rounding down e.g. 5//2 = 2). It's because on every display of 2 pages there are 2 consecutive pages e.g. (2,3), (3,4) etc. All we gotta do is just see if we can get from 0->p by turning p//2 pages or from n->p which is n//2-p//2.