목록PROGRAMMING (318)
MY MEMO
#define _CRT_SECURE_NO_WARNINGS #include #include using namespace std; vectorDP(201, vector(201, -1)); int Decom(int N, int k) { int&ret = DP[N][k]; if (ret != -1) return ret; int result = 0; for (int j = N; j >= 0; j--) result = (result + Decom(j, k - 1)) % 1000000000; return ret = result % 1000000000; } int main() { int N, k; scanf("%d %d", &N, &k); for (int j = 0; j
#define _CRT_SECURE_NO_WARNINGS #include #include using namespace std; vectormap(101, vector(101)); vectorDP(101, vector(101, -1)); int max_line; long long jump(int x, int y) { if (x == max_line - 1 && y == max_line - 1) return 1; long long &ret = DP[x][y]; if (ret != -1) return ret; long long num1 = 0, num2 = 0; if (x + map[x][y] < max_line && map[x][y] != 0) num1 = jump(x + map[x][y], y); if (..
#define _CRT_SECURE_NO_WARNINGS #include #include using namespace std; //시간초과 int row, col; vectormap, DP; int stair(int x, int y) { int&ret = DP[x][y]; if (x == row - 1 && y == col - 1) return ret = 1; if (ret != -1) return ret; ret = 0; int num1=0, num2=0, num3=0, num4=0; if (x + 1 < row && map[x + 1][y] < map[x][y]) num1 = stair(x + 1, y); if (y + 1 < col && map[x][y + 1] < map[x][y]) num2 = ..
#define _CRT_SECURE_NO_WARNINGS #include #include #include using namespace std; int n; vectormap(501, vector(501)), DP(501, vector(501, -1)); int eating(int x, int y) { int&ret = DP[x][y]; if (ret != -1) return ret; int num1 = 0, num2 = 0, num3 = 0, num4 = 0; if (x + 1 map[x][y]) num1 = eating(x + 1, y); if (y + 1 map[x][y]) num2 = eating(x, y + 1); ..
#define _CRT_SECURE_NO_WARNINGS #include #include using namespace std; int main() { int n; scanf("%d", &n); vectorDP(2, vector(3, 0)); for (int j = 0; j < 3; j++) DP[0][j] = 1; int k = 0; long long answer = 0; for (int j = 0; j < n - 1; j++) { DP[!k][0] = (DP[k][0] + DP[k][1] + DP[k][2]) % 9901; DP[!k][1] = (DP[k][0] + DP[k][2]) % 9901; DP[!k][2] = (DP[k][0] + DP[k][1]) % 9901; k = !k; } k % 2 =..
#define _CRT_SECURE_NO_WARNINGS #include #include #include using namespace std; int main() { int n; vectormap(1001, 0), DP(1001, 0); scanf("%d", &n); for (int j = 0; j map[k]) Max = max(Max, DP[k]); } DP[j] = Max + 1; } Max = 0; for (int j = 0; j < n; j++) Max = max(Max,..
#include #include #include using namespace std; int dp[1001][1001]; int main() { string a, b; cin >> a >> b; int al_en = a.length(); int b_len = b.length(); for (int i = 0; i < al_en ; ++i) { for (int j = 0; j < b_len ; ++j) { if (a[i] == b[j]) dp[i + 1][j + 1] = dp[i][j] + 1; else dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]); } } cout
#include #include #include using namespace std; int eatCookie(vector cookies) { int answer = 0; int cookies_count = cookies.size(); vectorDP(cookies_count + 1, 0); for (int j = 0; j cookies[k]) if (Max < DP[k]) Max = DP[k]; } DP[j] = Max + 1; answer = max(answer, DP[j]); } return answer; } int main() { vector tes..
#include #include #include using namespace std; int change(int total, vector coin) { vectorcount(total + 1, 0); int coin_count = coin.size(); sort(coin.begin(), coin.end()); for (int j = 0; j < coin_count; j++) { count[coin[j]]++; for (int k = 1; coin[j] + k
#include #include #include #include using namespace std; //최대 공약수 long long gcd(long long A, long long B) { return (A%B == 0 ? B : gcd(B, A%B)); } //최소 공배수 long long lcm(long long A, long long B) { return A * B / gcd(A, B); } long long nlcm(vector num) { long long answer = 0; sort(num.begin(), num.end(), greater()); int num_count = num.size(); answer = num[0]; for (int j = 1; j < num_count; j++)..