这是一道比较简单的结论题。
不难发现,最小得分为 \((n+1)(m+1)-nm\),化简得到:
\[\begin{aligned} &(n+1)(m+1)-nm\\ = &nm+n+m+1-nm\\ =&n+m+1 \end{aligned} \]继续不难发现,最大得分应该是最小得分加上 \(\lfloor \frac{(n-2)(m-2)+nm}{4} \rfloor\) 的结果,化简,得到(忽略向下取整是因为 C++ 的除法是默认向下取整的):
\[\begin{aligned} &n+m+1+\frac{(n-2)(m-2)+nm}{4}\\ =&\frac{4n+4m+4+(n-2)(m-2)+nm}{4}\\ =&\frac{4n+4m+4+nm-2n-2m+4+nm}{4}\\ =&\frac{2n+2m+8+2nm}{4}\\ =&\frac{n+m+nm}{2}+2 \end{aligned} \]然后算就行了。
#include <bits/stdc++.h>
using namespace std;
int main(){
long long a, b;
cin >> a >> b;
cout << a + b + 1 << ' ' << (a + b + a * b) / 2 + 2;
}
标签:化简,xmascon21,frac,nm,题解,Bad,aligned
From: https://www.cnblogs.com/mayile/p/18117149/at_xmascon21_b