viv001's blog

By viv001, 11 years ago, In English

Hi!

I am glad to invite you to Infinitum April'14, a monthly contest restricted to mathematics domain, held on HackerRank.

Register at https://www.hackerrank.com/infinitum-apr14

It's a 4 day contest with 6 problems with problem statements in English, Russian and Chinese.

You can view the last month's challenges here: https://www.hackerrank.com/infinitum-mar14/challenges

This month, the problems are much more interesting, have more variety and are a little more difficult.

Looking forward to a great participation! :)

Full text and comments »

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

By viv001, 11 years ago, In English

Hi Coders!

You are welcome to participate in the first ever math programming contest to be held by Hackerrank on March 28. For more details and registration, follow the link below :

https://www.hackerrank.com/infinitum-mar14

Happy Coding :)

Full text and comments »

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

By viv001, 13 years ago, In English

Hi, I just took part in Codeforces Round #105 Div2 . I submitted a solution for problem D which failed on the first pretest. After the contest, I checked why my program had failed and found out that the answer that the judge received from my program and that which I received on my system were different for the same input! I am sure my code is correct but yet the judge receives a different output from it. Can someone tell me why this is happening. Below is my code (submission id — 1143031) :

long double A[1003][1003];

long double prob(long double b, long double w) {

if(w <= 0)
    return 0;

if(b==1)
    return (w/(w+b));

if(b <= 0)
    return 1;

if(A[(int)b][(int)w] != -1)
    return A[(int)b][(int)w];

long double ans = w/(w+b) + (b/(w+b))*(b-1)/(w+b-1)*( (w/(w+b-2))*prob(b-2, w-1) + ( (b-2)/(w+b-2) )*prob(b-3, w));
A[(int)b][(int)w] = ans;
return ans;

}

int main() { long double w, b, ans;

int i, j;

scanf("%Lf%Lf", &w, &b);

for(i=0;i<=w;i++)
    for(j=0;j<=b;j++)
       A[j][i] = -1;

printf("%.12Lf\n", prob(b, w));
return 0;

}

Full text and comments »

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