전체 글(331)
-
[BOJ] 1476번 : 날짜 계산
1. problem : https://www.acmicpc.net/problem/1476 2. solution 1:#include using namespace std;int e, s, m; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}int lcm(int a, int b) { return a / gcd(a, b) * b;}int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> e >> s >> m; e--, s--, m--; int i = e; while (i % 28 != s) i += 15; int l = lcm(15, 28); while (i % 19 != m..
2024.10.04 -
[BOJ] 2133번: 타일 채우기
1. problem : https://www.acmicpc.net/problem/2133 2. solution 1 :#include using namespace std;int d[33];int main(void) { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; d[0] = 1, d[2] = 3; for (int i = 3; i = 0; j -= 2) { d[i] += d[j] * 2; } } cout source code 출처 : https://github.com/encrypted-def/basic-algo-lecture/blob/master/0x10/solutions/2133.cpp basic-algo-lecture/0x10/solutions..
2024.10.03 -
[BOJ] 9613번 : GCD 합
1. problem : https://www.acmicpc.net/problem/9613 2. solution 1 :#include using namespace std;int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}int main(void) { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; long long ans = 0; int a[105]; for (int i = 0; i > a[i]; for (int i = 0; i gcd를 직접 구현하여, 문제를 풀었다. ans는 100억이 될 수 있기 때문에, l..
2024.10.03 -
[BOJ] 2294번 : 동전 2
1. problem : https://www.acmicpc.net/problem/2294 2. solution 1 :#include using namespace std;const int val = 10005;int coins[val]; int d[val];int main(void) { ios::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; for (int i = 1; i > coins[i]; d[0] = 0; for (int i = 1; i i) continue; if (d[i-coins[c]] == 10001) continue; d[i] = min(d[i], d[i - coins[c]] + 1); } } if (d[k] == 1..
2024.10.03 -
[BOJ] 1676번 : 팩토리얼 0의 개수
1. problem : https://www.acmicpc.net/problem/1676 2. solution 1 :#include using namespace std;int n; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n; int cnt = 0; for (int i = 5; i 0이 생기기 위해서는 10이 곱해져야 한다. 10은 2 * 5로, 2와 5의 배수를 찾으면 된다. 하지만, 2의 배수보다 5의 배수가 적기 때문에, 5의 배수의 개수를 세면 된다. 이때, 5의 제곱수는 5의 개수가 제곱승만큼 존재하게 된다. 예를 들어, 5^2은 5가 2개 존재한다. 따라서, 5의 배수, 25의 배수 그리고 125의 배수를 차례차례 더해줘야 ..
2024.10.02 -
[BOJ] 4883번 : 삼각 그래프
1. problem : https://www.acmicpc.net/problem/4883 2. solution 1 :#include using namespace std;const int val = 100005;int d[val][4]; int a[val][4];int main(void) { ios::sync_with_stdio(0); cin.tie(0); int t = 0; while (true) { t++; int n; cin >> n; if (n == 0) return 0; for (int i = 1; i > a[i][j]; } d[1][1] = INT_MAX; d[1][2] = a[1][2]; d[1][3] = a[1][2] + a[1][3]; for (int i = 2;..
2024.10.02