UVa 264 - Count on Cantor

264 - Count on Cantor

 * http://acm.uva.es/p/v2/264.html

Summary
No point in brute forcing this thing 10^7 will take a long time :)

Explanation
The best we can do at this point is to figure out which value it starts at on the left side.

We can generalize this pattern in order to figure out the fraction.

Try to sum up all the numbers sequentially until you have figured out the range in which your number will belong. If the number is an odd number it will be on the top ie. 1/odd # If it is even it will be on the left side ie. even #/1 Once we establish the range, you can simply figure out the distance from the current position and finish off the problem.

Gotchas

 * Any points one can easily overlook?
 * The correct way to understand ambiguous formulations?

Implementations
Notes/Hints on actual implementation here.

Optimizations
Optimizations here.

Input
Input Here

Output
Output Here