#include<iostream>
#include<string.h>
using namespace std;
int a[25][25];
int heng(int i,int j){
return a[i][j]*a[i][j+1]*a[i][j+2]*a[i][j+3];
}
int shu(int i,int j){
return a[i][j]*a[i+1][j]*a[i+2][j]*a[i+3][j];
}
int xie(int i,int j){
int temp1=0;
int temp2=0;
if(i+3<=20&&j+3<=20){
temp1 = a[i][j]*a[i+1][j+1]*a[i+2][j+2]*a[i+3][j+3];
}
if(i+3<=20&&j-3<=20)
{
temp2=a[i][j]*a[i+1][j-1]*a[i+2][j-2]*a[i+3][j-3];
}
return temp1>temp2?temp1:temp2;
}
int main()
{
int max = -1;
int temp;
for(int i=1;i<=20;i++){
for(int j=1;j<=20;j++){
cin>>a[i][j];
}
}
for(int i=1;i<=20;i++){
for(int j=1;j<=20;j++){
if(j+3<=20){
temp = heng(i,j);
if(temp>max){
max = temp;
}
}
if(i+3<=20){
temp = shu(i,j);
if(temp>max){
max = temp;
}
}
temp = xie(i,j);
if(temp>max){
max = temp;
}
}
}
cout<<max<<endl;
return 0;
}
答案:70600674