본문 바로가기

Algorithm

(2139)
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 11656번:접미사 배열 답 1234567891011121314151617#include #include #include #include #include using namespace std;int main() { string s; cin >> s; int ss = s.size(); vector a; for (int i = 0; i
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 10699번:오늘 날짜 답 1234567891011121314151617#define _CRT_SECURE_NO_WARNINGS#include #include char* timeToString(struct tm *t);int main(void) { struct tm *t; time_t timer; timer = time(NULL); t = localtime(&timer); printf("%s\n", timeToString(t)); return 0;}char* timeToString(struct tm *t) { static char s[20]; sprintf(s, "%04d-%02d-%02d", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday); return s;}Colored by Color Scr..
(C++) - 백준(BOJ)코딩 10818번 : 최소, 최대 www.acmicpc.net/problem/10818 10818번: 최소, 최대 첫째 줄에 정수의 개수 N (1 ≤ N ≤ 1,000,000)이 주어진다. 둘째 줄에는 N개의 정수를 공백으로 구분해서 주어진다. 모든 정수는 -1,000,000보다 크거나 같고, 1,000,000보다 작거나 같은 정수이다. www.acmicpc.net loop를 사용해 최소, 최대를 찾아 출력하는 문제였습니다. Code #include using namespace std; int a[1000001], b = -1000001, s = 1000001,n; int main() { cin >> n; for (int i = 0; i > a[i]; if (b ..
(C++) - 백준(BOJ) 3040번 : 백설 공주와 일곱 난쟁이 #include using namespace std; int main() { int d[10],c[10],a=0,b,sum;//a,b는 가짜 난쟁이 for (int i = 1; i > d[i]; for(int r = 1; r
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 10824번:네 수 답 123456789101112131415161718192021222324252627#include #include using namespace std;int main() { string a, b, c, d; long long ans=0,xs,ys; cin >> a >> b >> c >> d; string x = a + b; string y = c + d; xs = x.size(); ys = y.size(); for (int i = 0; i
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 10707번:수도요금 답 1234567891011121314151617#include using namespace std;int main() { int a, b, c, d, p; int x, y; cin >> a >> b >> c >> d >> p; x = a * p;//x사의 수도요금 if (c
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 5988번:홀수일까 짝수일까 답 1234567891011121314151617#include #include using namespace std;int main() { int t; char k[61]; cin >> t; while (t--) { memset(k, 0, sizeof(k)); cin >> k; if (k[strlen(k) - 1] % 2 == 0) cout
(C++) - 백준(BOJ) 1717번 : 집합의 표현 https://www.acmicpc.net/problem/1717 1717번: 집합의 표현 첫째 줄에 n(1 ≤ n ≤ 1,000,000), m(1 ≤ m ≤ 100,000)이 주어진다. m은 입력으로 주어지는 연산의 개수이다. 다음 m개의 줄에는 각각의 연산이 주어진다. 합집합은 0 a b의 형태로 입력이 주어진다. 이는 www.acmicpc.net union-find로 풀었습니다. 📕 풀이방법 📔 입력 및 초기화 1. 입출력이 많으니 c와의 동기화를 풀어줍니다. 2. n, m을 입력해줍니다. 3. parent배열을 선언해줍니다. 처음에 i번 원소의 부모는 자기 자신입니다. 이때 번호가 1번부터 시작하므로 n번째까지 loop를 돌며 초기화해줘야 합니다. 3. m번동안 op, a, b를 입력해주며 실행합..