HDU 4438 Hunters(模拟)

题目链接:HDU 4438 Hunters

模拟。

很简单的题目,两种情况(Alice先选tiger或者Alice先选wolf)算出来比一下大小就行了。

#include <iostream>
#include <iomanip>

using namespace std;

int t, x, y;
double p, q;
double tiger, wolf;

int main()
{
    cin >> t;
    while(t--)
    {
        cin >> x >> y >> p >> q;
        tiger = q * (x * p + y * p) + (1.0 - q) * x;
        wolf = q * y + (1.0 - q) * (x * p + y * p);
        if(tiger > wolf)
        {
            cout << "tiger ";
            cout << fixed << setprecision(4) << tiger << endl;
        }
        else
        {
            cout << "wolf " ;
            cout << fixed << setprecision(4) << wolf << endl;
        }
    }
    return 0;
}


你可能感兴趣的:(HDU 4438 Hunters(模拟))