ural 1200

推出公式  然后特判两端  代码其实挺烂      但是有人竟然可以直接暴过去的 ...... 

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
    double A,B;
    int c;
    scanf("%lf%lf%d",&A,&B,&c);
    int _maxb,_maxc;
    double _maxa = -100000;
    for(int p = 0; p <= c; p++)
    {
        int d = (int)((A+2*p-B)/4);
        if(d < 0)
            d = 0;
        if(d > p)
            d = p;
        for(int j = d-1; j <= d+1; j++)
        {
            if(j >= 0 && p-j >= 0)
            {
                double k = j*A+(p-j)*B - j*j- (p-j)*(p-j);
                if(k > _maxa)
                {
                    _maxa = k;
                    _maxb = j;
                    _maxc = p-j;
                }
            }
        }
    }
    printf("%.2lf\n",_maxa);
    printf("%d %d\n",_maxb,_maxc);
    return 0;
}


posted @ 2013-08-05 12:50  xlc2845  阅读(122)  评论(0)    收藏  举报