분류 전체보기 (86) 썸네일형 리스트형 백준 11660번 구간 합 구하기 5 https://www.acmicpc.net/problem/11660 아이디어:1. 구간 합 구하기의 2차원 배열로 확장2. (2, 2) ~ (3, 4) 합은이 아닌이다.3. 원본 배열과 합 배열을 따로 만들고, 합 배열은 (1, 1)부터 (i, j)까지의 합으로 표현D[i][j] = D[i][j - 1] + D[i - 1][j] - D[i - 1][j - 1] + A[i][j]4. 원하는 구간 합 (x1, y1) ~ (x2, y2) = answeranswer = D[x2][y2] - D[x1 - 1][y2] - D[x2][y1 - 1] + A[x1 - 1][y - 1] // 11660#include using namespace std;int table[1025][1025] = { {0} };int D[1.. 백준 11659번 구간 합 구하기 https://www.acmicpc.net/problem/11659 아이디어:1. 현재 인덱스 까지의 총 합을 구하는 배열 int S[] 생성2. S[i] = S[i - 1] + A[n] (ex A: 1 2 3 4 5, S: 1 3 6 10 15)3. 구간 i ~ j 까지의 합은 S[j] - S[i - 1]과 동일4. 문제의 인덱스에 맞춰 배열의 크기는 S[100001], 순회는 (int i = 1, i 5. S[0] 은 0으로 두고 S[1]부터 A[1] 과 동기화// 11659#include using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int N, M, i, j; int A[1000.. 백준 1546번 평균 https://www.acmicpc.net/problem/1546 아이디어:1. (과목별 점수) / (최고점) * 100 의 새로운 평균2. {(A / max * 100) + (B / max * 100) + (C / max * 100)} / 3 = {(A + B + C) / max * 100 / 3}3. 과목별 점수는 배열로 저장받고 총 합을 구해준다.4. 마지막에 수식 적용 // 1546#include #include using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n, max = 0; int score[1000]; float answer = 0; cin >> n; for (int i = 0; i > sco.. 백준 11720번 숫자의 합 https://www.acmicpc.net/problem/11720아이디어:1. 문자열로 숫자 입력 받기2. 문자열 순회하면서 덧셈3. string[i] (char형)을 숫자로 변환할 때 string[i] - '0' // 11720#include #include using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n, answer = 0; string numbers = ""; cin >> n >> numbers; for (int i = 0; i 백준 4153번 직각삼각형 https://www.acmicpc.net/problem/4153 아이디어:1. int형 배열[3] 선언해서 정렬2. 정렬은 algorhithm의 sort() 사용 // 4153#include #include using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(NULL); int leng[3]; while (true) { cin >> leng[0] >> leng[1] >> leng[2]; if (leng[0] == 0) break; sort(leng, leng + 3); if ((leng[0] * leng[0]) + (leng[1] * leng[1]) == (leng[2] * leng[2])) cout 이전 1 ··· 9 10 11 12 13 14 15 ··· 18 다음