diff --git "a/hyeokbini/1025.\354\240\234\352\263\261\354\210\230 \354\260\276\352\270\260/1025.cpp" "b/hyeokbini/1025.\354\240\234\352\263\261\354\210\230 \354\260\276\352\270\260/1025.cpp" new file mode 100644 index 0000000..443848e --- /dev/null +++ "b/hyeokbini/1025.\354\240\234\352\263\261\354\210\230 \354\260\276\352\270\260/1025.cpp" @@ -0,0 +1,67 @@ +#include + +using namespace std; + +int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; +int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1}; +int ans = -1; + +void check(int val) +{ + int root = (int)sqrt(val); + if (root * root == val && ans < val) + { + ans = val; + } + return; +} + +int main() +{ + ios::sync_with_stdio(false); + cin.tie(0); + //freopen("test.txt", "rt", stdin); + int n, m; + cin >> n >> m; + vector> arr(n, vector(m)); + for (int i = 0; i < n; i++) + { + string tmp; + cin >> tmp; + for (int j = 0; j < m; j++) + { + arr[i][j] = tmp[j] - '0'; + } + } + // 시작 위치 지정 + for (int i = 0; i < n; i++) + { + for (int j = 0; j < m; j++) + { + // 한칸 단위도 체크 + check(arr[i][j]); + for (int mulx = -n; mulx <= n; mulx++) + { + for (int muly = -m; muly <= m; muly++) + { + if (mulx == 0 && muly == 0) + { + continue; + } + int curx = i; + int cury = j; + int tempval = 0; + while (curx < n && curx >= 0 && cury < m && cury >= 0) + { + tempval *= 10; + tempval += arr[curx][cury]; + check(tempval); + curx += mulx; + cury += muly; + } + } + } + } + } + cout << ans; +} \ No newline at end of file diff --git a/hyeokbini/README.md b/hyeokbini/README.md index ed8dc8d..182728a 100644 --- a/hyeokbini/README.md +++ b/hyeokbini/README.md @@ -22,3 +22,4 @@ | 18차시 | 2025.08.07 | 브루트포스 | [약속 장소](https://www.acmicpc.net/problem/25542)|[#18](https://github.com/AlgoLeadMe/AlgoLeadMe-15/pull/66)| | 19차시 | 2025.08.10 | 브루트포스 | [리모컨](https://www.acmicpc.net/problem/1107)|[#19](https://github.com/AlgoLeadMe/AlgoLeadMe-15/pull/68)| | 20차시 | 2025.08.14 | 완전탐색,DFS | [모음사전](https://school.programmers.co.kr/learn/courses/30/lessons/84512)|[#20](https://github.com/AlgoLeadMe/AlgoLeadMe-15/pull/72)| + | 21차시 | 2025.08.19 | 브루트포스 | [제곱수 찾기](https://www.acmicpc.net/problem/1025)|[#21](https://github.com/AlgoLeadMe/AlgoLeadMe-15/pull/76)|