백준
[골3] 10986 - 나머지 합 구하기
#pragma region 입출력 속도향상 #define FAST_IO() \ {\ ios::sync_with_stdio(false);\ cin.tie(NULL); \ cout.tie(NULL); \ }\ #pragma endregion #include #include using namespace std; int main() { FAST_IO(); int n, m; cin >> n >> m; vector v(n + 1), c(m); vector s(n + 1); long ans = 0; for (int i = 1; i > tmp; v[i] = (v[i - 1] + tmp) % m; ans += (v[i] == 0); c[v[i]]++; } for (const auto& val : c) ans += (va..
[골5] 1806 - 부분합
#include #include #include using namespace std; #define MAX 987654321 int main() { int n, r; cin >> n >> r; vector v(100001); for (int i = 0; i > v[i]; int s = 0, e = 0, res = MAX; int sum = v[0]; while (true) { if (sum >= r) { res = min(res, e - s + 1); sum -= v[s++]; } else { if (++e == n) break; sum += v[e]; } } cout
[실3] 3273 - 두 수의 합
#include #include #include using namespace std; int main() { int n; cin >> n; vector v(n); for (int i = 0; i > v[i]; sort(v.begin(), v.end()); int x; cin >> x; int s = 0, e = n - 1, cnt = 0; while (s < e) { int a = v[s], b = v[e]; int sum = a + b; if (sum == x) cnt++; if (sum < x) s++; else e--; } cout
[골5] 2294 - 동전2
#include #include #pragma region 입출력 속도향상 #define FAST_IO() \ {\ ios::sync_with_stdio(false);\ cin.tie(NULL); \ cout.tie(NULL); \ }\ #pragma endregion using namespace std; int main() { FAST_IO(); int n, k; cin >> n >> k; vector v(n), dp(k + 1); for (int i = 0; i > v[i]; for (int i = 1; i
[실3] 11659 - 구간 합 구하기 4
#include #include using namespace std; #pragma region 입출력 속도향상 #define FAST_IO() \ {\ ios::sync_with_stdio(false);\ cin.tie(NULL); \ cout.tie(NULL); \ }\ #pragma endregion int main() { FAST_IO(); int n, m; cin >> n >> m; vector v(n + 1), t(n + 1); // 입력 for (int i = 1; i > v[i]; // 구간합 구하기 for (int i = 1; i > s >> e; cout
[골5] 1106 - 호텔
#include #include #include using namespace std; #pragma region 입출력 속도향상 #define FAST_IO() \ {\ ios::sync_with_stdio(false);\ cin.tie(NULL); \ cout.tie(NULL); \ }\ #pragma endregion #define MAX 100000 int main() { FAST_IO(); int c, n; cin >> c >> n; vector v; for (int i = 0; i > a >> b; v.push_back({ a,b }); } int dp[MAX + 1] = { 0 }; for (int i = 0; i < v.size(); i++) ..
[골5] 12904 - A와 B
#include #include #include using namespace std; #pragma region 입출력 속도향상 #define FAST_IO() \ {\ ios::sync_with_stdio(false);\ cin.tie(NULL); \ cout.tie(NULL); \ }\ #pragma endregion int main() { FAST_IO(); string s, t; cin >> s >> t; while (t.length() != s.length()) { if (t.back() != 'A') { t.pop_back(); reverse(t.begin(), t.end()); } else t.pop_back(); } cout
[실1] 2527 - 직사각형
#include #include using namespace std; int main() { int x1, y1, p1, q1, x2, y2, p2, q2; int xr, xl, yb, yt, xdiff, ydiff; for (int i = 0; i > x1 >> y1 >> p1 >> q1 >> x2 >> y2 >> p2 >> q2; xl = max(x1, x2); xr = min(p1, p2); yb = max(y1, y2); yt = min(q1, q2); xdiff = xr - xl; ydiff = yt - yb; if (xdiff > 0 && ydiff > 0) cout
[실1] 1629 - 곱셈
#include using namespace std; long long A, B, C; long long POW(int A, int B, int C) { if (B == 0) return 1; long long temp = POW(A, B/2, C); temp = temp * temp % C; if (B % 2 == 0) return temp; //짝수 일때 else return temp * A % C; //홀 수 일때 } int main(void) { cin >> A >> B >> C; cout
[실1] 1309 - 동물원
#include int D[100001]={1,3}; int main() { int N; std::cin>>N; for(int i=2;i