전체 글(331)
-
[BOJ] 1654번 : 랜선 자르기
1. problem : https://www.acmicpc.net/problem/1654 2. solution 1 :#include using namespace std;int k, n;int nums[10005];typedef long long ll;int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> k >> n; for (int i = 0; i > nums[i]; ll left = 1ll; ll right = *max_element(nums, nums + k); ll answer = 0; while (left = n) { left = mid + 1; answer = mid; } } cout
2024.09.01 -
[C++] typdedef 와 #define의 차이
featuretypedef#define유효 범위정의된 유효 범위 내에서만 유효정의된 후 파일의 끝까지 유효타입 체크타입으로 처리됨단순히 텍스트 치환 (타입으로 인식되지 않음)디버깅 지원디버깅 시에도 타입으로 인식텍스트로 치환되어 디버깅이 어려움에러 방지타입 안전성을 보장예기치 않은 치환으로 오류 가능성 존재typedef long long ll; #define ll long long; typedef로 long long을 ll로 별칭하는순간, ll은 진짜 long long이 된다. #define ll long long를 적으면,선행처리기가 ll을 long long으로 바꾼다. 그다음에, compile 한다.
2024.09.01 -
[BOJ] 2193번 : 이친수
1. problem : https://www.acmicpc.net/problem/2193 2. solution 1 :#include using namespace std;int n;long long d[95]; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n; d[1] = 1, d[2] = 1; for (int i = 3; i 3. solution 2 :// Authored by : Hot6Mania// Co-authored by : -// http://boj.kr/62b94c1ad9254f87a1f6e37323f2c5bf#include using namespace std;typedef long long ll;int n;ll d[100][..
2024.09.01 -
[BOJ] 11727번 : 2 x n 타일링 2
1. problem : https://www.acmicpc.net/problem/11727 2. solution 1 :#include using namespace std;int n;int d[1005]; int main(void) { ios::sync_with_stdio(0); cin.tie(0); d[1] = 1; d[2] = 3; for (int i = 3; i > n; cout 3. solution 2 :#include int dp[1001];int rec(int x){ if (x == 1) return 1; if (x == 2) return 3; if (dp[x] != 0) { return dp[x]; } return dp[x] = ( rec(x-1) + 2 * rec(x-2) ) % 1..
2024.09.01 -
[BOJ] 1932번 : 정수 삼각형
1. problem : https://www.acmicpc.net/problem/1932 2. solution 1 :#include using namespace std;int n;int d[505][505]; int trees[505][505]; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n; int depth = 0; for (int i = 1; i > trees[i][j]; // 각 층의 몇번째 가지인지 표현; } d[1][1] = trees[1][1], d[2][1] = trees[2][1] + d[1][1], d[2][2] = trees[2][2] + d[1][1]; for (int i = 3; i 3. solution 2..
2024.09.01 -
[BOJ] 1003번 : 피보나치 함수
1. problem : https://www.acmicpc.net/problem/1003 2. solution 1 :#include using namespace std;int t; vector> d(42,{0,0}); // {0 cnt, 1 cnt};int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> t; while (t--) { int n; cin >> n; d[0] = { 1,0 }, d[1] = { 0,1 }; for (int i = 2; i 3. solution 2 :// Authored by : heheHwang// Co-authored by : -// http://boj.kr/0a669ebf1000436b94e3067b..
2024.09.01