본문 바로가기

분류 전체보기

(698)
5644. 무선 충전 #define ABS(X) ((X > 0) ? X : -X) using namespace std; typedef struct { int y, x, c, p; }BC; static int M, A; static int d[5][2] = { 0, 0, //dont move -1, 0, //up 0, 1, //right 1, 0, //down 0, -1 //left }; //문제에서 제시하는 방향을 정확히 볼 것, static int find_max(vector& used, const vector & BCs) { int max = 0; //used가 사용할 수 있는 BC들의 리스트 중 충전양이 최대인 것을 찾는다. for (int i = 0; i < used.size(); i++) { int idx = use..
5650. 핀볼게임 #define UP 0 #define DOWN 1 #define LEFT 2 #define RIGHT 3 using namespace std; static int N; static int board[100][100]; static int d[4][2] = { -1, 0, 1, 0, 0, -1, 0, 1 }; //row: y, column: x static int changed[4][6] = { DOWN, DOWN, RIGHT, LEFT, DOWN, DOWN, UP, RIGHT, UP, UP, LEFT, UP, RIGHT, UP, DOWN, RIGHT, RIGHT, RIGHT, LEFT, LEFT, LEFT, DOWN, UP, LEFT }; //row: current direction, column: ob..
8673 static int K; static int tables[2][100000]; static int cnt[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024 }; static int solution(void) { int n, loop, turn = 0, tot = 0; scanf("%d", &K); for (int i = 0; i 0) { for (int i = 0, j = 0; i tables[turn][i + 1]) { tables[1 - tu..
2112 static int D, W, K; static int board[13][20]; static int injection[13]; static int ans; static bool find_ans; static bool check(int (*tmp)[20]) { bool ret = true; for (int x = 0; x < W && ret; x++) { int priv = tmp[0][x], cnt = 1; for (int y = 1; y < D && cnt < K; y++) { if (tmp[y][x] == priv) //실수한 부분 cnt += 1; else { priv = tmp[y][x]; //실수한 부분 cnt = 1; } } if (cnt != K) ret = false; } return r..
8659 static long long table[91][2]; //실수했던 부분 static int K; static void table_init(void) { table[1][0] = 2; table[1][1] = 1; for (int i = 2; i b; gcd(a, b) = gcd(b, a % b) a > b = 0; gcd(a, 0) = a 이렇게 재귀적으로 구할 수 있다. 문제에서는 해당작업의 반복횟수가 주어졌을 때, 그 횟수를 만족하는 여러개의 두 수의 집합 중, a가 제일 작고, 제일 작은 a가 여러개 일 경우 제일 작은 b가 되는 집합을 출력하는 것이다. 그래서 시작을 (a, 0) 으로 잡고 시작했다. 여기서 a == 1로 하고 거슬러 올라가면 된다. (1, 0) -> (2, 1) 이 되어야 한다..
8658 static void solution(void) { int number; int max = 0, min = 0x7FFFFFFF; for (int i = 0; i max) max = s; if (s < min) min = s; } printf("%d %d\n", max, min); } 10진수 값에서 각 자리수만 추출하여 더하면 되는 간단한 문제이다.
5650 static int N; static int board[100][100]; static int map_y[11][100]; static int map_x[11][100]; static int d[4][2] = { -1, 0, //up, 0 1, 0, //down, 1 0, -1, //left, 2 0, 1 //right, 3 }; static int changed[4][6] = { 1, 1, 3, 2, 1, 1, 0, 3, 0, 0, 2, 0, 3, 0, 1, 3, 3, 3, 2, 2, 2, 1, 0, 2 }; static bool out_of_bound(int y, int x) { if (y = N) return true; if (x = N) return true; ..
1949 static int N, K; static int board[8][8]; static int start[5][2]; //최고봉 위치는 최대 5개, static int d[4][2] = { -1, 0, //up 1, 0, //down 0, -1, //left 0, 1 //right }; static int visit[8][8]; static int max_len; static inline bool out_of_bound(int y, int x) { if (y = N) return true; if (x = N) return true; return false; } static void __solution(int y, int x, int len, int is_cut) { if..
8568 static int N; static int permu[1000]; static int solution(void) { int tmp, ret = 0; list cache[3][3]; //해당 위치에서 필요한 나머지, 실제 나머지, 값의 위치 scanf("%d", &N); for (int i = 1; i
8567 static int table[100000 + 1]; static int ans[100000 + 1]; static int N; static void table_init() { for (int i = 1; i