思路:
我们考虑使用容斥计算整个图形的面积,将其补全为一个大长方形,与该图形面积之差为 ,注意到有一个小坑:第一格不算推的,所以推的步数应为 。
通过举例子发现转弯次数只与 有关,具体的,为 ,那么本题已经出来了。
代码:
#include <iostream>
#include <cmath>
#include <algorithm>
#define int long long
using namespace std;
inline int read() {
int f = 1, x = 0;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch <= '9' && ch >= '0') {
x = x * 10 + (ch - '0');
ch = getchar();
}
return f * x;
}
inline void write(int x) {
if (x < 0) {
x = -x;
putchar('-');
}
if (x > 9) write(x / 10);
putchar(x % 10 + '0');
}
const int N = 45, INF = 0x3f3f3f3f;
int a[N], base[N];
signed main(void) {
int w = read(), x = read(), y = read();
write((x + w) * (y + w) + 3 * w - 3 - x * y);
return 0;
}