-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProblem 11.cpp
75 lines (68 loc) · 1.69 KB
/
Problem 11.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//ANSWER IS 70600674
//EXECTUION PROCESS TAKES 5.467 SECONDS
#include<iostream>
using namespace std;
int main()
{
int a[20][20];
for(int i=0;i<20;i++)
{
for(int j=0;j<20;j++)
cin>>a[i][j];
}
long long max=a[1][1]*a[1][2]*a[1][3]*a[1][4],check=1;
int i,j,k;
for(int i=0;i<20;i++)
{ check=1;
cout<<i<<" ";
for(j=0;j<17;j++)
{ check=1;
cout<<j<<"\n";
for(k=0;k<4;k++)
check*=a[i][j+k];
if(check>max)
max=check;
}
}
cout<<"\n\n1 "<<max<<"\n\n";
for(int i=0;i<17;i++)
{ cout<<i<<" ";
check=1;
for(j=0;j<20;j++)
{ check=1;
cout<<j<<"\n";
for(k=0;k<4;k++)
check*=a[i+k][j];
if(check>max)
max=check;
}
}
cout<<"\n\n2 "<<max<<"\n\n";
for(i=0;i<17;i++)
{
cout<<i<<" ";
for(j=0;j<17;j++)
{ check=1;
cout<<j<<"\n";
for(k=0;k<4;k++)
check*=a[i+k][j+k];
if(check>max)
max=check;
}
}
cout<<"\n\n3 "<<max<<" \n\n";
for(i=3;i<20;i++)
{ check=1;
cout<<i<<" ";
for(j=3;j<20;j++)
{
cout<<j<<"\n";
check=1;
for(k=0;k<4;k++)
check*=a[i-k][j+k];
if(check>max)
max=check;
}
}
cout<<"\n\n"<<max;
}