From 9e28e4c7b67c54229df11d355047ac8a88ea1817 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Sun, 15 Dec 2019 15:09:13 +0700 Subject: Normalize pathname --- THT/C/TP-2017/squares.c | 59 ------------------------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 THT/C/TP-2017/squares.c (limited to 'THT/C/TP-2017/squares.c') diff --git a/THT/C/TP-2017/squares.c b/THT/C/TP-2017/squares.c deleted file mode 100644 index 9ed7317..0000000 --- a/THT/C/TP-2017/squares.c +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include - -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) - -struct poin_t { - short x, y; -}; - -int main() -{ - FILE *f = fopen("squares.inp", "r"); - short m, n, i, j, x, y, mini, maxi, minj, maxj, _minj, _maxj; - char k, c, net[1001][1001] = {}; - long long count = 0; - struct poin_t *e; - - fscanf(f, "%hd %hd %hhd\n", &m, &n, &k); - for (i = 1; i < MIN(m, n); i++) - count += (long long) i * (m - i) * (n - i); - e = malloc(k * sizeof(struct poin_t)); - for (i = 0; i < k; i++) { - fscanf(f, "%hd %hd\n", &e[i].x, &e[i].y); - net[e[i].x][e[i].y] = 1; - } - fclose(f); - - for (count *= 12; k--; e++) { - x = (*e).x; - y = (*e).y; - mini = MAX(x - m, 1 - y); - maxi = MIN(x - 1, n - y); - _minj = MAX(1 - x, 1 - y); - _maxj = MIN(m - x, n - y); - for (i = mini; i <= maxi; i++) { - minj = MAX(MAX(i - x + 1, 1 - y - i), _minj); - maxj = MIN(MIN(m - x + i, n - y - i), _maxj); - for (j = minj; j <= maxj; j++) { - if (!i && !j) - continue; - c = 1; - if (net[x - i][y + j]) - c++; - if (net[x + j][y + i]) - c++; - if (net[x - i + j][y + i + j]) - c++; - count -= 12 / c; - } - } - } - - f = fopen("squares.out", "w"); - fprintf(f, "%Ld\n", count / 12); - fclose(f); - - return 0; -} -- cgit 1.4.1