#include<stdio.h> int x, y, tx, ty, cnt, n, m, k, dir, fx[] = { -1,0,1,0 }, fy[] = { 0,1,0,-1 }; int map[1010][1010]; int main() { scanf("%d %d", &m, &n); scanf("%d", &k); int i, tmpx, tmpy; x = n; y = 1; cnt = 1; dir = 0; for (i = 1; i <= n*m; i++) { if (cnt == k) { tx = x; ty = y; } map[x][y] = cnt++; tmpx = x + fx[dir]; tmpy = y + fy[dir]; if (map[tmpx][tmpy] != 0 || tmpx <= 0 || tmpx>n || tmpy <= 0 || tmpy>m) dir = (dir + 1) % 4; x += fx[dir]; y += fy[dir]; } if (n*m<k) printf("0"); else printf("%d %d", ty, n + 1 - tx); return 0; }
10157번: 자리배정
https://www.acmicpc.net/problem/10157
피드 구독하기:
댓글
(
Atom
)
댓글 없음 :
댓글 쓰기