Sort 4 Discussions, By:
Please Login in order to post a comment
Solved this problem finally after a couple of failed trials.
For whomever it may help:
PS "Easy" is not the right category for this problem if you ask me...
n // A being the count of fractions with denominator A where was a key insight I've failed to notice for a long time. I was also thinking "Easy" is crazy for such a problem which takes pages of editorial on the official site.
n // A
In retrospect, to begin with this concept in mind, figuring out the removal of fractions in non-reduced form would be straightforward, consider we should have been very familiar with similar techniques from prime sieve, Totient function and more generally, dynamic programming.
What is the test case #10?
I got a "wrong answer" for #10 only. Thanks!
Never mind. I found it was due to integer outflow
can any one advice how to get better run time for gcd() function
In many languages, there are inbuilt functions for calculating gcd. Use them.
... or don't use gcd at all.
even though i used the farey sequence in c my time hasent reduced. only 2 test case are accepted.
use something else then
I'm completely new to c n still learning. It would be a great help if u could point me in the right direction.
No more comments