목록C++ (124)
정화 코딩

https://www.acmicpc.net/problem/21919 #include #include #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector a = vector(n); for (int i = 0; i > a[i]; } int cnt = 0; long long ans = 1; for (int x: a) { //! bool isPrime = true; double tmp = sqrt(x); if (tmp * tmp == x) { ..

https://www.acmicpc.net/problem/11723 #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int m, n; string op; cin >> m; int now = 0; for (int i = 0; i > op; if (op == "add") { cin >> n; now = now | (1 > n; if ((now & (1 > n; if ((now & (1 > n; now = now ^ (1 (정답) 비트..

AtCoder Beginner Contest 354 (https://atcoder.jp/contests/abc354) A. Exponential Plant https://atcoder.jp/contests/abc354/tasks/abc354_a //C++#include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int h; cin >> h; int curh = 0; int day = 0; int growth = 1; while (curh (정답) B. AtCoder Janken 2 https://atcoder.jp/contests/abc35..

https://www.acmicpc.net/problem/1012 #include #include #include using namespace std;int dn[4] = {0, 0, -1, 1};int dm[4] = {-1, 1, 0, 0};int m, n, k;int cnt = 0;vector> g;void bfs(vector start) { queue> q; cnt++; q.push(start); g[start[0]][start[1]] = 0; while (!q.empty()) { vector cur = q.front(); q.pop(); for (int i = 0; i = 0 && tn = 0 && tm > tn; for (in..

EDOC 2024-1 5회차 정모 (골드: 동적 계획법 알아보기 3) A https://www.acmicpc.net/problem/13270 첫번째 풀이#include #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector minD(n + 1, 0); vector maxD(n + 1, 0); minD[1] = maxD[1] = 0; minD[2] = maxD[2] = 1; if (n >= 3) minD[3] = maxD[3] = 2; int x1 = 2; int ..

https://www.acmicpc.net/problem/7569 #include #include #include using namespace std;int dh[6] = {0, 0, 0, 0, 1, -1};int dn[6] = {1, -1, 0, 0, 0, 0};int dm[6] = {0, 0, -1, 1, 0, 0};vector>> box;int m, n, h;int t = 0;bool check() { for (int i = 0; i > q; for (int i = 0; i cur = q.front(); q.pop(); for (int x = 0; x = 0 && ni = 0 && nj = 0 && nk > m >> n >> h; bo..

5/12. 바이러스 (백준 2606번) https://www.acmicpc.net/problem/2606 //C++#include #include #include using namespace std;vector visited;vector> g;int n;int bfs(int start) { queue q; int cnt = 0; q.push(start); visited[start] = true; while (!q.empty()) { int cur = q.front(); q.pop(); for (int nxt: g[cur]) { if (!visited[nxt]) { q.push(nxt); ..

거리의 합 2 (백준 23330번) https://www.acmicpc.net/problem/23330문제 해석이런식으로 n개의 점이 수직선 위에 놓여 있고, 모든 점들의 쌍에 대해 두 점 사이의 거리의 합을 구하는 문제이다. 첫번째 풀이우선 가장 직관적인 풀이로 풀어보자. //C++#include #include #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector data(n); for (int i = 0; i > data[i]; } long long sum = 0; for (int i ..