区间规律=》第一次遇见这类题目(记录复习)
作者:
虎头虎脑
,
2022-04-19 09:22:22
,
所有人可见
,
阅读 172
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int n;
int a[3], b[3];
int both()
{
if (n <= 5) return n * n * n;
int res = 1;
for (int i = 0; i < 3; i ++ )
{
int d = abs(a[i] - b[i]);
res *= max(0, 5 - d) + max(0, 5 - (n - d));
}
return res;
}
int single()
{
int res = 1;
for (int i = 0; i < 3; i ++ )
res *= min(n, 5);
return res;
}
int main()
{
cin >> n;
for (int i = 0; i < 3; i ++ ) cin >> a[i];
for (int i = 0; i < 3; i ++ ) cin >> b[i];
cout << single() * 2 - both() << endl;
return 0;
}
参考y总代码