/*
TASK:combo
LANG:C++
URL:http://train.usaco.org/usacoprob2?a=E6RZnAhV9zn&S=combo
SOLVE:自己做,想的是5*5*5*2-重复计算的。
官方题解是超级简单地写个判断枚举每一种解是否可行(n^3),题目没给n的范围,我就认为不可以用O(n^3)的算法。
*/
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#define ll long long
using namespace std;
int n,a[30][40];
ll ans=1;
int main() {
freopen("combo.in","r",stdin);
freopen("combo.out","w",stdout);
scanf("%d",&n);
for(int i=1;i<=2;i++)
for(int j=1;j<=3;j++)
scanf("%d",&a[i][j]);
ll s=min(5,n);
if(n<=5)ans=s*s*s;
else
for(int j=1;j<=3;j++)
ans*=s-min(s,(ll)min(abs(a[1][j]-a[2][j]),n-abs(a[1][j]-a[2][j])));
printf("%lld\n",s*s*s*2-ans);
}
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有