Bob_and_Vagene's blog

By Bob_and_Vagene, history, 8 years ago, In English

Problem link : http://www.spoj.com/problems/PYTRIP/

I am not able to think of any other solution except brute force and also, i am unable to find any pattern or something. If anyone could please give me a hint in approaching the problem or provide a reference to any material that you think might be helpful would be great.

  • Vote: I like it
  • +3
  • Vote: I do not like it

»
8 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

You can observe that a=sqrt(2*c-1) and b=c-1. Iterate from n to m and check for every i if sqrt(2*i-1)*sqrt(2*i-1) = 2*i-1. For c=1 there is no solution cause b=c-1=0.

»
44 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

You can use Euclid's formula