본문 바로가기

Algorithm

(2139)
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 10610번:30 답 1.자릿수 중 0 을 포함(2 or 5의 배수)2.모든 자릿수의 합이 3의 배수 3.가장 큰 숫자 순으로 정렬하여 출력.정수론에 따라 이 세가지 조건을 만족하면 30의 배수 중 가장 큰 놈입니다.123456789101112131415161718192021222324252627#include #include #include using namespace std;int t;bool z;char num[100001];bool cmp(const int &a, const int &b){ return a > b;//내림차순으로 정렬 - > 가장 큰 수를 출력하기 위함}int main() { cin >> num; int snum = strlen(num); for (int i = 0; i
(C++) - 백준(BOJ) 10814번 : 나이순 정렬 답 https://www.acmicpc.net/problem/10814 stable_sort()를 이용하면 나이가 같을 때 정렬의 순서가 유지되게 정렬할 수있습니다. 123456789101112131415161718192021222324252627//stable_sort()를 이용하면 나이가 같을 때 정렬의 순서가 유지되게 정렬할 수 있습니다.#include #include #include #include using namespace std;struct account { int age; string name;};bool cmp(const account &a, const account &b){ return a.age > n; vector a(n); for (int i = 0; i > a[i].age; cin ..
(C++) - 백준(BOJ) 6378 : 디지털 루트 답 #include #include using namespace std;int main() { int ans; char k[1001]; while (1) { cin >> k; if (k[0]=='0') { break; } while (1) { ans = 0; for (int i = 0; i
(C++) - 백준(BOJ) 5347번 : LCM 답 #include using namespace std; long long t, a, b; long long GCD(long long a, long long b) { if (a > t; while (t--) { cin >> a >> b; cout
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 3460번:이진수 답 비트마스크 문제입니다. 123456789101112131415161718#include using namespace std;int main() { int n, t; cin >> t; while (t--) { cin >> n; for (int i = 0; i
(C++) - 백준(BOJ) 11943번 : 파일 옮기기 www.acmicpc.net/problem/11943 11943번: 파일 옮기기 첫 번째 줄에는 첫 번째 바구니에 있는 사과와 오렌지의 수 A, B가 주어진다. (0 ≤ A, B ≤ 1,000) 두 번째 줄에는 두 번째 바구니에 있는 사과와 오렌지의 수 C, D가 주어진다. (0 ≤ C, D ≤ 1,000) www.acmicpc.net #include using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; int ans = (b + c) < (a + d) ? (b + c) : (a + d); cout
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 9076번:점수 집계 답 12345678910111213141516171819202122232425262728293031323334353637383940414243#include using namespace std;int t, b, bi, s, si, a[5],ans;int main() { cin >> t; while (t--) { b = 0; s = 11; bi = 0; si = 0; ans = 0; for (int i = 0; i > a[i]; if (a[i] >= b)//최대값 { b = a[i]; bi = i; } if (a[i]
(C, C++) - 백준(BOJ) 11659 : 구간 합 구하기 4 https://www.acmicpc.net/problem/11659 11659번: 구간 합 구하기 4 첫째 줄에 수의 개수 N과 합을 구해야 하는 횟수 M이 주어진다. 둘째 줄에는 N개의 수가 주어진다. 수는 1,000보다 작거나 같은 자연수이다. 셋째 줄부터 M개의 줄에는 합을 구해야 하는 구간 i와 j www.acmicpc.net 누적합 문제였습니다. 풀이방법 누적합입니다. Code C언어 #include int a[100001], s[100001], n, m, x,y; int main() { scanf("%d %d", &n, &m); for (int i = 1; i > n >> m; for(int i = 1; i > num[i], sum[i] = sum[i-1] + num[i]; for(int i ..