Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double Calc(int x, int y, int map[111][111], int n, int w) {
- double res = 0;
- int t1 = 5, t2;
- if (n == 3) t1 = 3;
- t2 = t1 - 1;
- for (int j = y - t2; j <= y; ++j) {
- if (j < 0 || j + t2 >= n) continue;
- int c = 1;
- for (int t = 0; t < t1; ++t) {
- if (!map[x][j + t]) continue;
- if (map[x][j + t] != w) {
- c = 0;
- break;
- } else ++c;
- }
- if (c == 1) c = 0;
- if (c) res += pow(3.0, c + .0);
- if (c == t1)
- if (w == 2) res += 100000;
- else res += 1000;
- }
- for (int i = x - t2; i <= x; ++i) {
- if (i < 0 || i + t2 >= n) continue;
- int c = 1;
- for (int t = 0; t < t1; ++t) {
- if (!map[i + t][y]) continue;
- if (map[i + t][y] != w) {
- c = 0;
- break;
- } else ++c;
- }
- if (c == 1) c = 0;
- if (c) res += pow(3.0, c + .0);
- if (c == t1)
- if (w == 2) res += 100000;
- else res += 1000;
- }
- for (int i = x - t2, j = y - t2; i <= x; ++i, ++j) {
- if (i < 0 || j < 0 || i + t2 >= n || j + t2 >= n) continue;
- int c = 1;
- for (int t = 0; t < t1; ++t) {
- if (!map[i + t][j + t]) continue;
- if (map[i + t][j + t] != w) {
- c = 0;
- break;
- } else ++c;
- }
- if (c == 1) c = 0;
- if (c) res += pow(3.0, c + .0);
- if (c == t1)
- if (w == 2) res += 100000;
- else res += 1000;
- }
- for (int i = x + t2, j = y - t2; i >= x; --i, ++j) {
- if (i >= n || j < 0 || i - t2 < 0 || j + t2 >= n) continue;
- int c = 1;
- for (int t = 0; t < t1; ++t) {
- if (!map[i - t][j + t]) continue;
- if (map[i - t][j + t] != w) {
- c = 0;
- break;
- } else ++c;
- }
- if (c == 1) c = 0;
- if (c) res += pow(3.0, c + .0);
- if (c == t1)
- if (w == 2) res += 100000;
- else res += 1000;
- }
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment