본문 바로가기
반응형

알고리즘27

[cpp 알고리즘] 백준 1003 피보나치 함수 c++ 1. 문제 2. 풀이 3. 코드 #include using namespace std; int T,N; int dp[50][2]; int main(){ // input cin >> T; dp[0][0]=1; dp[0][1]=0; dp[1][0]=0; dp[1][1]=1; for(int i=2; i> N; cout 2022. 7. 13.
[cpp 알고리즘] 백준 2839 설탕배달 c++ 1. 문제 2. 풀이 3. 코드 #include #include using namespace std; int N; int dp[1001][5]; int ans =0; int main(){ // input cin >> N; // 마지막 자릿수 확인 if(N%10==0 || N%10==5){ ans = N/5; } else if(N%10==1 || N%10==6){ ans = 2+(N-3*2)/5; } else if(N%10==2 || N%10==7){ ans = 4+(N-3*4)/5; } else if(N%10==3 || N%10==8){ ans = 1+(N-3*1)/5; } else if(N%10==4 || N%10==9){ ans = 3+(N-3*3)/5; } // except if(N==4 || N=.. 2022. 7. 13.
[SQL] 문법 정리 SELECT문 SELECT select_list [ INTO new_table ] [ FROM table_source ] [ WHERE search_condition ] [ GROUP BY group_by_expression ] [ HAVING search_condition ] [ ORDER BY order_expression [ ASC | DESC ] ] INTO : 조건에 맞는 기존 테이블의 열 내용을 새 테이블로 가져와 테이블을 만드는 것 GROUP BY : 그룹 ORDER BY : 정렬 HAVING: 특정 컬럼을 그룹화한 결과에 조건을 걸 때 사용 WHERE는 그룹화 하기 전, HAVING은 그룹화 한 후에 조건 프로그래머스 예제 1. 모든 동물의 정보를 ANIMAL_ID 순으로 조회 SELECT.. 2022. 3. 16.
[해시] 위장 1. 문제 요약 - 서로 다른 옷의 조합 구하기 2. 풀이 - 옷의 종류가 string으로 저장되어 있으니 map에 를 저장한다. - map의 iterator를 통해 저장되어 있는 옷의 개수를 구해올 수 있다. 3. 코드 //틀린 코드 #include #include #include using namespace std; int solution(vector clothes) { int answer = 0; map m; for(int i=0; i 1) { for (auto iter = m.begin(); iter != m.end(); iter++) { temp *= iter->second; } answer += temp; return answer; } else { return answer; } } 더보기 무조.. 2022. 3. 14.
반응형