ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1200. Horns and Hoofs

Alyosha Popovich I cant get AC.. please help.. here is my program // Problem 1200. Horns and Hoofs 19 Mar 2002 22:39
#include <stdio.h>
#include <math.h>

long double A, B;
int K;
int Ba, Bb;
long double Best;

#define eps 0.001

void solve()
{
    long double p, pb;
    int a, b;
    for (a = K, b = 0, pb = 0; a >= 0; a--)
    {
        p = (K-a)*(B - K+a);
        if (p > pb+eps) pb = p, b = K-a;
        p = a*(A - a) + pb;
        if (p > Best-eps) Best = p, Ba = a, Bb = b;
    }
}

void main()
{
    scanf("%Lf %Lf %d", &A, &B, &K);
    solve();
    printf("%.2Lf\n%d %d\n", Best, Ba, Bb);
}