为了防止有重复的数字,我开了个三维数组来标记,爆内存,又用vector标记,爆内存...
不得不感慨这份代码.
/* ID:wang9621 PROG:combo LANG:C++ */ #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <vector> using namespace std; int n; bool close(int a,int b) { if(abs(a-b)<=2||abs(a-b)>=(n-2)) return true; return false; } bool judge(int m1,int m2,int m3,int n1,int n2,int n3) { return close(m1,n1)&&close(m2,n2)&&close(m3,n3); } int main() { freopen("combo.in","r",stdin); freopen("combo.out","w",stdout); scanf("%d",&n); int a,b,c; int e,f,g; cin>>a>>b>>c; cin>>e>>f>>g; int count = 0; for(int i = 1; i<=n; i++) for(int j = 1; j<=n; j++) for(int k = 1; k<=n; k++) if(judge(i,j,k,a,b,c)|| judge(i,j,k,e,f,g)) count++; printf("%d\n",count); return 0; }