문제(요약) 부분문자열의 갯수를 구하시오. (출처) 접근법 완전탐색구현 후, 시간초과 발생하여 Dynamic Programing (Memoization) 적용 풀이 #include #include using namespace std; string S; string sT = "SAMSUNG"; const int NUM = 1000000007; vector memo; int fnSolve(int IdxT, int IdxS) { if (sT.size() == IdxT) { return 1; } if (S.size() == IdxS) { return 0; } int Ret = memo[IdxT][IdxS]; if (Ret != -1) { return Ret; } if (sT[IdxT] == S[IdxS]) { ..
전체 글
프로그래밍, 알고리즘과 자료구조 그리고 각종 개발도구의 사용법을 주로 기록하고자 했으나, 어느새 생활정보도 추가하게 되었습니다.풀이 #include #include using namespace std; vector SubSet; vector Seq(6); int n; int fnSolve(int idx,/* 고려하는 SubSet Index */ int cnt /* 선택한 갯수 */) { if (idx > n) { return 0; } if (cnt == 6) { cout
풀이 #include #include using namespace std; // next_permutaion 을 사용하면 쉽게 풀이 가능 int main() { string str; while (cin >> str) { if (str[0] == '#') { break; } bool val = next_permutation(str.begin(), str.end()); if (val == false) { cout
풀이 #include using namespace std; FILE* stream; int main(void) { //freopen_s(&stream, "Text.txt", "r", stdin); int D, F, H; float U; // Double 사용하면 답이 달라짐 while (cin >> H >> U >> D >> F) { if (H == 0) { break; } float f = U * F / 100; // Double 사용하면 답이 달라짐 float i = 0; // Double 사용하면 답이 달라짐 int d = 1; while (true) { // Day i += U; if (U > 0) U -= f; // Leave if (i > H) { break; } //cout
#include using namespace std; // FILE* stream; int main(void) { // freopen_s(&stream, "Text.txt", "r", stdin); int T; cin >> T; for (int t = 0; t > N; for (int i = 0; i > s; if (s > max) { max = s; } } cout
풀이 #include using namespace std; #define MAX_W 13 int main(void) { int N, B, H, W; while (cin >> N >> B >> H >> W) { int cP = 987654321; for (int i = 0; i > P; for (int j = 0; j > w; if (w >= N && P*N
풀이 #include using namespace std; int main(void) { int t; cin >> t; for (int i = 0; i > a >> b; if (a == b) { cout
문제(요약) 8821. 적고 지우기 풀이 문자열에 홀수번 등장하는 숫자의 개수를 구합니다. 입력받는 숫자의 범위가 '0' ~ '9' 로 제한되므로 입력받을 때마다 개수를 증가시키고 이 값이 홀수인 경우를 답으로 산출합니다. 단, 문자열로 입력받게 되므로 이를 숫자형으로 변환할 필요가 있습니다. #include #include using namespace std; int main(int argc, char** argv) { int T; cin >> T; for (int i = 0; i > strNum; for (int j = 0; j < s..