dhruvmullick's blog

By dhruvmullick, history, 9 years ago, In English

I was doing TRIPINV. The problem requires us to find triplets with ai > aj > ak for i < j < k.

I was thinking of using 2 BITs for the same, and use a (Sum) C (2), and of sum of (SameElements) C (2). But I can't maintain the order of elements this way. For instance, in A[1..6] = 3 2 1 3 2 1 My program would identify A[2],A[5],A[6] as a triplet too.

Can anyone help me out?

PS: C denotes Combination

Full text and comments »

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

By dhruvmullick, 9 years ago, In English

I saw a solution for Little Pony and Expected Maximum but couldn't really understand why it works. Can someone explain the logic behind it?
I have seen the tutorial, but it doesn't explain this approach.

double p = m;
for(int i = 1; i < m; i++)
    p -= pow((double) i / m, n);
printf("%.16f\n", p);

Full text and comments »

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