Algorithm(218)
-
[BOJ] 10816번 : 숫자 카드 2
1. problem : https://www.acmicpc.net/problem/10816 2. solution 1 : #include using namespace std;int n, m; vector v1; vector v2; vector ans; int lower_search_func(int& a) { int left = 0, right = n; while (left = a) right = mid; else left = mid + 1; } return left; }int upper_search_func(int& a) { int left = 0, right = n; while (left > n; for (int i = 0; i > x; v1.push_back(x); } cin >> m; f..
2024.11.13 -
[BOJ] 1920번 : 수 찾기
1. problem : https://www.acmicpc.net/problem/1920 2. solution 1 :#include using namespace std;int N, M; vector v1; vector v2; bool find_num(int& a) { int left = 0; int right = N-1; while (left > N; for (int i = 0; i > x; v1.push_back(x); } sort(v1.begin(), v1.end()); cin >> M; for (int i = 0; i > x; v2.push_back(x); } for (int i = 0; i binary search를 이용해 답을 도출했다. binary search를 하기 위해서는 ..
2024.10.31 -
[BOJ] 1038번 : 감소하는 수
1. problem : https://www.acmicpc.net/problem/1038 2. solution 1 :#include using namespace std;vector v(10, 0);int main(void) { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int cnt = 0; for (int i = 1; i source code 출처 : https://github.com/encrypted-def/basic-algo-lecture/blob/master/0x12/solutions/1038.cpp basic-algo-lecture/0x12/solutions/1038.cpp at master · encrypted-def/basic-algo..
2024.10.11 -
[BOJ] 1011번 : Fly me to the Alpha Centauri
1. problem : https://www.acmicpc.net/problem/1011 2. solution 1 :#include using namespace std;long long func(long long a) { return (2 * sqrt(a) - 1e-9);}int main(void) { ios::sync_with_stdio(0); cin.tie(0); int t; long long x, y; cin >> t; while (t--) { cin >> x >> y; cout source code 출처 : https://github.com/encrypted-def/basic-algo-lecture/blob/master/0x12/solutions/1011.cpp basic-algo-lec..
2024.10.10 -
[BOJ] 2482번 : 색상환
1. problem : https://www.acmicpc.net/problem/2482 2. solution 1 :#include using namespace std;int n, k; const int val = 1004;const int mod = 1e9 + 3;int d[val][val]; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> k; if (k == 1) { cout source code 참고 : https://akim9905.tistory.com/71 [백준] 2482번 색상환[적용한 알고리즘] DP [아이디어] 1번과 N번이 둘 다 색칠되는 경우를 제외하고는, 나머지 경우는 선형으로 생각해줘도 된다. dp[N]..
2024.10.08 -
[BOJ] 11660번 : 구간 합 구하기 5
1. problem : https://www.acmicpc.net/problem/11660 2. solution 1 :#include using namespace std;const int val = 1030; int board[val][val];int d[val][val];int main(void) { ios::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; for (int i = 1; i > board[i][j]; } for (int i = 1; i > x1 >> y1 >> x2 >> y2; int ans = d[x2][y2] - d[x2][y1 - 1] - d[x1 - 1][y2] + d[x1 - 1][y1 - 1]; cout dp를..
2024.10.07