분류 전체보기
-
백준 20164 홀수 홀릭 호석PS 2021. 4. 8. 02:14
www.acmicpc.net/problem/20164 #include #include #include using namespace std; #define INF 987654321 int n; int big = -INF; int small = INF; int counting(string str) { int cnt = 0; for(int i = 0; i < str.size(); i++) { int num = str[i] - '0'; if (num % 2 == 1) { cnt++; } } return cnt; } string divideAndAdd(int p, int q, string str) { string a = ""; string b = ""; string c = ""; int A, B, C; for (..
-
백준 1780번 종이의 개수PS 2021. 4. 8. 02:09
www.acmicpc.net/problem/1780 #include #include #include using namespace std; #define MAX 2188 int n; int oneCnt, zeroCnt, moneCnt; int map[MAX][MAX]; void counting(int num) { if (num == -1) { moneCnt++; } else if (num == 0) { zeroCnt++; } else { oneCnt++; } } void solve(int y, int x, int size) { if (size == 1) { counting(map[y][x]); return; } bool br = false; for (int i = y; i < y + size; i++) {..
-
백준 13171 APS 2021. 4. 6. 19:03
www.acmicpc.net/problem/13171 #include #include #include using namespace std; #define M 1000000007 long long A, X; long long Ax[65]; int main() { cin >> A; cin >> X; A %= M; Ax[0] = A; for (int i = 1; i < 64; i++) { Ax[i] = (Ax[i - 1] * Ax[i - 1]) % M; } long long tX = X; long long res = 1; while (tX != 0) { if (tX % 2) { res *= Ax[dep]; res %= M; } tX /= 2; } cout
-
백준 1629 곱셈PS 2021. 4. 6. 05:51
곱셈 + 큰 수 -> mod #include #include using namespace std; long long ret(int a, int b, int c) { if (b == 0) return 1; long long half = ret(a, b / 2, c); if (b % 2 == 0) { return (half * half) % c; } else { return ((half * half) % c * a) % c; } } int main() { int a, b, c; cin >> a >> b >> c; cout
-
백준 1992번 쿼드트리PS 2021. 4. 4. 23:29
www.acmicpc.net/problem/1992 탐색하고 분할하고. 분할1을(를) 탐색하고 분할2을(를) 탐색하고 분할3을(를) 탐색하고 분할4을(를) 탐색하고 ... #include #include #include using namespace std; #define MAX 64 int n; int map[MAX][MAX]; string retZip(int y, int x, int size) { if (size == 1) { return to_string(map[y][x]); } bool zero = true, one = true; for (int i = y; i < y + size; i++) { for (int j = x; j < x + size; j++) { if (map[i][j]) { zero..
-
백준 11729번 하노이 탑 이동순서PS 2021. 4. 2. 04:34
www.acmicpc.net/problem/11729 분할하기 #include #include #include using namespace std; int n; int res; vector v; void move(int dep, int from, int to) { if (dep == 1) { res++; v.push_back(make_pair(from, to)); return; } int tmp; for (int i = 1; i > n; move(n, 1, 3)..