목록알고리즘문제들 (25)
VioletaBabel
#include#include#include#include#include#includeusing namespace std;bool check(string in, set c);int main(int argc, char** argv){int T, test_case;string chemical[114] = {"h", "he", "li", "be", "b", "c", "n", "o", "f", "ne","na", "mg", "al", "si", "p", "s", "cl", "ar", "k", "ca","sc", "ti", "v", "cr", "mn", "fe", "co", "ni", "cu", "zn","ga", "ge", "as", "se", "br", "kr", "rb", "sr","y", "zr","nb"..
#includeusing namespace std;int main(int argc, char** argv){int Answer, *tower, temp[3];long long total;int T, test_case, n, now;setbuf(stdout, NULL);scanf("%d", &T);for (test_case = 0; test_case < T; test_case++){total = 0, Answer = 0, now = 0;scanf("%d", &n);tower = new int[n];for (int i = 0; i < n; ++i){scanf("%d", &tower[i]);total += tower[i];}while (total != 0){for(int i = 0; i < 3; ++i)tem..
#includeusing namespace std;long long Answer;int main(int argc, char** argv){setbuf(stdout, NULL);char move[300001];int T, test_case, x, y, n, k, temp;scanf("%d", &T);for (test_case = 0; test_case < T; test_case++){scanf("%d %d", &n, &k);x = y = 1;Answer = 1;scanf("%s", &move);for (int i = 0; i < k; ++i, Answer += temp){if (move[i] == 'U')y -= 1;else if (move[i] == 'D')y += 1;else if (move[i] ==..
#include#includeusing namespace std;int Answer, degVal[40] = { 6,13,13,4,4,18,18,1,1,20,20,5,5,12,12,9,9,14,14,11,11,8,8,16,16,7,7,19,19,3,3,17,17,2,2,15,15,10,10,6 };int main(int argc, char** argv){setbuf(stdout, NULL);int T, test_case, a, b, c, d, e, n, x, y, score, degree;double l;scanf("%d", &T);for (test_case = 0; test_case < T; test_case++){Answer = 0;scanf("%d %d %d %d %d %d", &a, &b, &c,..
#include#includeusing namespace std;int Answer, num[200000];int main(int argc, char** argv){setbuf(stdout, NULL);int T, test_case, n, k;scanf("%d", &T);for (test_case = 0; test_case < T; test_case++){Answer = 0;scanf("%d %d", &n, &k);for (int i = 0; i < n; ++i)scanf("%d", &num[i]);sort(&num[0], &num[n]);for (int i = 1; i
#include#includeusing namespace std;int Answer;int main(int argc, char** argv){setbuf(stdout, NULL);int T, test_case, now, n;set num;scanf("%d", &T);for (test_case = 0; test_case < T; test_case++){Answer = -1;scanf("%d", &n);for (int i = 0; i < n; ++i){scanf("%d", &now);if (num.count(now))num.erase(num.find(now));elsenum.insert(now);}for (set::iterator iter = num.begin(); iter != num.end(); ++it..
#include#includeusing namespace std;int Answer, p[300000];int main(int argc, char** argv){int T, test_case, n, max = 0;setbuf(stdout, NULL);scanf("%d", &T);for (test_case = 0; test_case max) ? p[i] + (n - i) : max;for (int i = 0; i < n; ++i)Answer ..
[배열] 숫자값을 인풋으로 받아서 정렬된 정수배열에서 얼마나 등장하는지 찾기 (제한 시간복잡도 O(log N)) 예를들어 3과 [1,1,3,3,4,4,4] 이 나오면 3이 두번 나오므로 2. 입력31 1 2 2 3 3 4 5 출력2==================== #includeint main(){int fn, temp, cnt = 0;for (scanf("%d", &fn); scanf("%d", &temp) != EOF;)cnt = (fn == temp) ? (cnt + 1) : cnt;printf("%d", cnt);}//입력을 받으면서 바로 카운트를 세어보았습니다. ======================= #include#includeusing namespace std;int main(){ve..
#include int main(){int t, e, f, realMem, n, mem[10001], *appTime, *appMem;scanf("%d", &t);for (int i = 0; i < t; ++i){for (int j = 1; j < 10001; ++j)mem[j] = 500000000;mem[0] = 0;scanf("%d %d %d", &e, &f, &n);realMem = f - e;appTime = new int[n];appMem = new int[n];for (int j = 0; j < n; ++j)scanf("%d %d", &appTime[j], &appMem[j]);for (int j = 0; j < n; ++j)for (int k = 0; k
#include int choigong(int *a, int *b);int count;int main(){int big, small;scanf("%d %d", &big, &small);if (big < small){count = big;big = small;small = count;}count = 0;choigong(&big, &small);printf("최대공약수 : %d\n", small);} int choigong(int *a, int *b){int x = *a, y = *b;printf("%d회 진행. %d, %d\n", ++count, x, y);if (x % y == 0){*a = x;*b = y;}else{*a = y;*b = x % y;choigong(a, b);}}