Showing posts with label Mathematics. Show all posts
Showing posts with label Mathematics. Show all posts

Wednesday, 20 January 2016

Solution of URI 1323 :: UVA 12149 :: LIVE ARCHIVE 4215 :: Feynman


Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.

/**Bismillahir Rahmanir Rahim.**/

#include <stdio.h>
int main()
{
    int a,b;
    while(1)
    {
        scanf("%d", &a);
        if(a==0) break;
        else b=(a*(a+1)*((2*a)+1))/6;
        printf("%d\n",b);
    }
    return 0;
}


Saturday, 9 January 2016

Solution of LIGHT OJ 1311 :: Unlucky Bird


Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.

/**Bismillahir Rahmanir Rahim.**/

#include <stdio.h>
int main()
{
    int tst, i;
    double v1, v2, v3, a1, a2, t, t1, t2, fly, d1, d2;
    scanf("%d", &tst);
    for(i=1; i<=tst; i++)
    {
        scanf("%lf%lf%lf%lf%lf", &v1, &v2, &v3, &a1, &a2);
        t1 = v1/a1;
        t2 = v2/a2;
        t = t1;
        if(t2>t1) t = t2;
        d1 = (v1*v1)/(2*a1);
        d2 = (v2*v2)/(2*a2);
        fly = t*v3;
        printf("Case %d: %lf %lf\n", i, d1+d2, fly);
    }
    return 0;
}