전체 글(331)
-
[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 -
[BOJ] 9657번 : 돌 게임 3
1. problem : https://www.acmicpc.net/problem/9657 2. solution 1 :#include using namespace std;vector winners = { "SK","CY" };int n; vector rocks = { 1,3,4 }; int d[1005]; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n; d[1] = 0, d[2] = 1, d[3] = 0, d[4] = 0; for (int i = 5; i source code 출처 : https://github.com/encrypted-def/basic-algo-lecture/blob/master/0x10/solutions/9657.c..
2024.10.06 -
[BOJ] 1520번 : 내리막 길
1. problem : https://www.acmicpc.net/problem/1520 2. solution 1 :#include using namespace std;int dx[4] = { 0,1,0,-1 };int dy[4] = { 1,0,-1,0 }; int n, m; int a[505][505], d[505][505]; int dp(int x, int y) { if (d[x][y] != -1) return d[x][y]; if (x == n - 1 && y == m - 1) return 1; int& ret = d[x][y]; ret = 0; for (int dir = 0; dir = n || ny = m) continue; if (a[x][y] > a[nx][ny]) ret += dp(..
2024.10.05