杭电多校第四场 Blow up the Enemy

题目传送
思路:
暴力即可,但是要注意,第一次俩者是不需要等待,直接发起攻击,所以在计算击杀对方时间的时候还要减去第一次所需要的时间

AC代码

#include 
inline long long read(){char c = getchar();long long x = 0,s = 1;
while(c < '0' || c > '9') {if(c == '-') s = -1;c = getchar();}
while(c >= '0' && c <= '9') {x = x*10 + c -'0';c = getchar();}
return x*s;}
using namespace std;
#define NewNode (TreeNode *)malloc(sizeof(TreeNode))
#define Mem(a,b) memset(a,b,sizeof(a))
#define lowbit(x) (x)&(-x)
const int N = 4e5 + 5;
const long long INFINF = 0x7f7f7f7f7f7f7f;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-7;
const int mod = 998244353;
const double II = acos(-1);
const double PP = (II*1.0)/(180.00);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> piil;
signed main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    //    freopen("input.txt","r",stdin);
    //    freopen("output.txt","w",stdout);
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        int val[n+5],dai[n+5];
        double Max = 0.00;
        for(int i = 1;i <= n;i++)
            cin >> val[i] >> dai[i];
        for(int i = 1;i <= n;i++)
        {
            int num = 100/val[i];
            if(100 % val[i] == 0 && num > 0) num--;
            int t = num*dai[i];//击杀对方所花费的时间
            double sum = 0;
            for(int j = 1;j <= n;j++)
            {
                int a = 100/val[j];
                if(100 % val[j] == 0 && a > 0) a--;
                int b = a*dai[j];//击杀对方所需的时间
                if(t < b)
                    sum = sum + 1.00/(n*1.00);
                else if(t == b)
                    sum = sum + 1.00/(n*1.00)*0.50;
            }
            Max = max(Max,sum);
        }
        cout << fixed << setprecision(6) << Max << endl;
    }
}

你可能感兴趣的:(HDU)