Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctime>
- #include <iostream>
- int grid[15][15] = {
- {75},
- {95, 64},
- {17, 47, 82},
- {18, 35, 87, 10},
- {20, 4, 82, 47, 65},
- {19, 1, 23, 75, 3, 34},
- {88, 2, 77, 73, 7, 63, 67},
- {99, 65, 4, 28, 6, 16, 70, 92},
- {41, 41, 26, 56, 83, 40, 80, 70, 33},
- {41, 48, 72, 33, 47, 32, 37, 16, 94, 29},
- {53, 71, 44, 65, 25, 43, 91, 52, 97, 51, 14},
- {70, 11, 33, 28, 77, 73, 17, 78, 39, 68, 17, 57},
- {91, 71, 52, 38, 17, 14, 91, 43, 58, 50, 27, 29, 48},
- {63, 66, 4, 68, 89, 53, 67, 30, 73, 16, 69, 87, 40, 31},
- {4, 62, 98, 27, 23, 9, 70, 98, 73, 93, 38, 53, 60, 4, 23}
- };
- int main() {
- int max = 0;
- int tmp;
- std::clock_t start;
- start = std::clock();
- for (int a = 0; a < 1; a++) {
- for (int b = 0; b < 2; b++) {
- for (int c = 0; c < 3; c++) {
- if (c != b + 1 && c != b)
- continue;
- for (int d = 0; d < 4; d++) {
- if (d != c + 1 && d != c)
- continue;
- for (int e = 0; e < 5; e++) {
- if (e != d + 1 && e != d)
- continue;
- for (int f = 0; f < 6; f++) {
- if (f != e + 1 && f != e)
- continue;
- for (int g = 0; g < 7; g++) {
- if (g != f + 1 && g != f)
- continue;
- for (int h = 0; h < 8; h++) {
- if (h != g + 1 && h != g)
- continue;
- for (int i = 0; i < 9; i++) {
- if (i != h + 1 && i != h)
- continue;
- for (int j = 0; j < 10; j++) {
- if (j != i + 1 && j != i)
- continue;
- for (int k = 0; k < 11; k++) {
- if (k != j + 1 && k != j)
- continue;
- for (int l = 0; l < 12; l++) {
- if (l != k + 1 && l != k)
- continue;
- for (int m = 0; m < 13; m++) {
- if (m != l + 1 && m != l)
- continue;
- for (int n = 0; n < 14; n++) {
- if (n != m + 1 && n != m)
- continue;
- for (int o = 0; o < 15; o++) {
- if (o != n + 1 && o != n)
- continue;
- tmp = grid[0][a] + \
- grid[1][b] + \
- grid[2][c] + \
- grid[3][d] + \
- grid[4][e] + \
- grid[5][f] + \
- grid[6][g] + \
- grid[7][h] + \
- grid[8][i] + \
- grid[9][j] + \
- grid[10][k] + \
- grid[11][l] + \
- grid[12][m] + \
- grid[13][n] + \
- grid[14][o];
- if (tmp > max) {
- max = tmp;
- printf("%d (%.3f seconds elapsed)\r\n", max, (std::clock() - start) / (double)CLOCKS_PER_SEC);
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- printf("MAX: %d\r\n", max);
- printf("Finished In:\r\n");
- printf(" %.3f Seconds.\r\n", ((std::clock() - start) / (double)CLOCKS_PER_SEC));
- printf(" %.2f Minutes.\r\n", ((std::clock() - start) / (double)CLOCKS_PER_SEC) / 60);
- printf(" %.3f Hours.\r\n", ((std::clock() - start) / (double)CLOCKS_PER_SEC) / 60 / 60);
- getchar();
- return 0;
- }
- /*
- OUTPUT:
- 794 (0.000 seconds elapsed)
- 852 (0.000 seconds elapsed)
- 855 (0.000 seconds elapsed)
- 891 (0.000 seconds elapsed)
- 907 (0.001 seconds elapsed)
- 916 (0.001 seconds elapsed)
- 934 (0.001 seconds elapsed)
- 940 (0.001 seconds elapsed)
- 955 (0.001 seconds elapsed)
- 964 (0.001 seconds elapsed)
- 982 (0.001 seconds elapsed)
- 988 (0.001 seconds elapsed)
- *** (0.001 seconds elapsed)
- **** (0.001 seconds elapsed)
- **** (0.001 seconds elapsed)
- **** (0.001 seconds elapsed)
- **** (0.001 seconds elapsed)
- **** (0.001 seconds elapsed)
- **** (0.001 seconds elapsed)
- **** (0.001 seconds elapsed)
- **** (0.002 seconds elapsed)
- MAX: ****
- Finished In:
- 0.002 Seconds.
- 0.00 Minutes.
- 0.000 Hours.
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement