rpthegreat's blog

By rpthegreat, history, 7 years ago, In English

Hello,

I am trying to find intersection area of given circles and a polygon.

My approach is ,

  • Calculate all intersection points ( intersection of all circles with polygon and all remaining circles).
  • Keep track of all arcs encountered in above step.
  • Now remove all intersection points which are not inside polygon or does not follow the equation of any circle. Also remove the arcs that start or end with this particular intersection point.
  • Now all points which are left after above, will be my bounded region. So using formula of finding area of polygon, i
    will find area (say area1 ) and then i will calculate area which is left due to arc(say area2) .
  • return area1+area2

Is my approach correct or not?

I know that to implement this problem, I need to use floating point arithmetic. Which points are important while implementing this problem?

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By rpthegreat, 7 years ago, In English

I am trying to solve a problem which is described below,

Given value of f(0) and k , which are integers.

I need to find value of f( T ). where T<=10^10 (10 power 10)

Recursive function is,

f(n) = 2*f(n-1) , if 4*f(n-1) <=k

k - ( 2*f(n-1) )      ,  if 4*f(n-1) > k

If i solve by brute force then it will give me TLE. The code will run 10^10(10 power 10) time in worst case that gives me Time Limit Exceed. I need more efficient solution for this problem. Please help me. I don't know the correct algorithm.

Full text and comments »

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

By rpthegreat, history, 7 years ago, In English

Hello, Given a tree (nodes and their weight) and query which contains two number node (of tree guaranteed )and value c . I need to find number of ancestors which has weight greater than c. I saved query and sorted according to their query value. I stored graph node and their respective weight in 2-D array and sorted according to their weight. I set bit array initially all zero and start visiting query array from last. Now how to use segment tree for query. Do i need to use another concept ? please help me . Thank you.

Full text and comments »

  • Vote: I like it
  • -8
  • Vote: I do not like it