[백준 12101번] 1, 2, 3 더하기 2 (C++)
문제링크 : https://www.acmicpc.net/problem/12101 12101번: 1, 2, 3 더하기 2 n을 1, 2, 3의 합으로 나타내는 방법 중에서 사전 순으로 k번째에 오는 것을 출력한다. k번째 오는 식이 없는 경우에는 -1을 출력한다. www.acmicpc.net #include using namespace std; typedef long long ll; typedef pair pii; const int MAX = 987654321; int n, k; vectorv; void func(int i, int idx, int sum, string tmp) //길이, 현재 인덱스, 누적합, 문자열 합 { if(idx==i) //목표 길이 도달 { if(sum==n) v.push_bac..
[백준 16195번] 1, 2, 3 더하기 9 (C++)
문제링크 : https://www.acmicpc.net/problem/16195 16195번: 1, 2, 3 더하기 9 각 테스트 케이스마다, n을 1, 2, 3의 합으로 나타내는 방법의 수를 1,000,000,009로 나눈 나머지를 출력한다. 단, 사용한 수의 개수는 m개 이하 이어야 한다. www.acmicpc.net #include using namespace std; typedef long long ll; typedef pair pii; const int MAX = 987654321; int T, n, m, dp[1001][1001]; const int MOD = 1000000009; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> T..