Spidey Distance
Time limit1sMemory limit1024 MB
Given taxi-cab distance t and Spidey distance s, output the reduced fraction of lattice points within Spidey distance s that are also within taxi-cab distance t.
- Level
Medium5 of 10
- Topics
- Math, Geometry, Implementation
- Solved
- No attempts yet
Problem
Consider a 2D plane of points with integer coordinates. The Taxi-cab Distance between two points is the length of the shortest path between them when movement is restricted to horizontal and vertical steps, like following the lines on graph paper. Each point connects to exactly four others, each one unit away.
The Spidey Distance is a similar shortest-path measure, but movement may also go diagonally. Horizontal and vertical neighbors are one unit apart, and diagonal neighbors are units apart. So each point connects to eight others: four at one unit and four at units.
Write a program that computes the fraction of points within a given Spidey Distance of a point that can also be reached within a given Taxi-cab Distance of that point.
Input
The single line of input contains two integers and (), where is a taxi-cab distance and is a spidey distance.
Output
Output a fraction in the form /, the fraction of points within the given spidey distance that can also be reached within the given taxi-cab distance. Reduce the fraction to lowest form. If , output only . Do not output any spaces around the /.