ACMT - Acm Teams

· · 题解

一道简单的数学题

这题可以分两种情况考虑:

第一种:如果 A 类人比 B 类人的两倍还多,则尽管每队都是两个 A 类人搭配一个 B 类人,B 类人还是不够。此时答案就是 B 类人的数量。

第二种:否则,只要合理分配,就可以每 3 人都组一队。此时答案是 \lfloor \frac{A+B}{3} \rfloor

AC 代码

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t,x,y;
    cin>>t;
    while(t--)
    {
        cin>>x>>y;
        if(max(x,y)>2*min(x,y))cout<<min(x,y)<<endl;
        else cout<<(x+y)/3<<endl;
    }
    return 0;
}

附上 AC记录