Find the gcd of n-1 differences ( a[1]..a[n-1] with a[0] )
ans = (a[n-1] - a[0])/gcd - n + 1

Thanks,
Balaji.


On Sat, Mar 12, 2011 at 2:00 PM, Akshata Sharma
<[email protected]>wrote:

> Any faster way to solve this problem??
>
> On 3/12/11, Balaji Ramani <[email protected]> wrote:
> > Yes, the correct answer is 0.
> >
> > "if(flag ==0 || ans ==0)" i think can be changed to "if(flag ==0)" alone.
> >
> > Thanks,
> > Balaji.
> >
> > On Sat, Mar 12, 2011 at 10:16 AM, Satyam Kapoor
> > <[email protected]>wrote:
> >
> >> is case main answer 0 hona chahiye.
> >> --
> >> Satyam Kapoor
> >> B.Tech 2nd year
> >> Computer Science And Engineering
> >> M.N.N.I.T ALLAHABAD
> >>
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Algorithm Geeks" group.
> >> To post to this group, send email to [email protected].
> >> To unsubscribe from this group, send email to
> >> [email protected].
> >> For more options, visit this group at
> >> http://groups.google.com/group/algogeeks?hl=en.
> >>
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> > http://groups.google.com/group/algogeeks?hl=en.
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to