You are not logged in. Please login at www.codechef.com to post your questions!

×

Solution for srm 635 easy problem

Try for each pair (i, j) of starting indices. Now, to compare them, first we have to transform both of them to start from zero. So all coordinates of the first part are seen as (x[k] - x[i], y[k] - y[i]) and similarly for second. Now the scaling factor for a particular pair can be calculated by finding the number which we should multiply the coordinates in the second part to get the corresponding coordinate in the first part. This is (x[j + 1] - x[j]) / (x[i + 1] - x[i]). Now we just keep looping till we can scale the second part to match the first part and calculate the distance in the first part. Take maximum of those. Seems like using double for the scaling factors causes precision problems. Hope i am clear.

This question is marked "community wiki".

asked 04 Oct '14, 23:37

balajiganapath's gravatar image

6★balajiganapath ♦♦
75542742
accept rate: 77%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×3,607
×5

question asked: 04 Oct '14, 23:37

question was seen: 974 times

last updated: 04 Oct '14, 23:37

Related questions