[백준] 10845: 큐
2020. 12. 29. 05:34
Problem set
10845번: 큐 첫째 줄에 주어지는 명령의 수 N (1 ≤ N ≤ 10,000)이 주어진다. 둘째 줄부터 N개의 줄에는 명령이 하나씩 주어진다. 주어지는 정수는 1보다 크거나 같고, 100,000보다 작거나 같다. 문제에 나와있지 www.acmicpc.net #include #include template struct Queue { T data[10000]; int begin, end; Queue() : begin(0), end(0) {} void push(int num) { if (empty()) { data[begin] = num; end++; } else { data[end++] = num; } } int pop() { if (empty()) { return -1; } return data[beg..
[백준] 10844: 쉬운 계단 수
2020. 12. 29. 05:33
Problem set
10844번: 쉬운 계단 수 첫째 줄에 정답을 1,000,000,000으로 나눈 나머지를 출력한다. www.acmicpc.net #include using namespace std; long long d[101][10]; long long mod = 1000000000; auto main()->int { int n; cin >> n; for (int i = 1; i
[백준] 10828: 스택
2020. 12. 29. 05:32
Problem set
10828번: 스택 첫째 줄에 주어지는 명령의 수 N (1 ≤ N ≤ 10,000)이 주어진다. 둘째 줄부터 N개의 줄에는 명령이 하나씩 주어진다. 주어지는 정수는 1보다 크거나 같고, 100,000보다 작거나 같다. 문제에 나와있지 www.acmicpc.net #include #include #include int main() { using namespace std; ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; stack s; while (n--) { string cmd; cin >> cmd; if (cmd == "push") { int num; cin >> num; s.push(num); ..
[백준] 10818: 최소, 최대
2020. 12. 29. 05:30
Problem set
10818번: 최소, 최대 첫째 줄에 정수의 개수 N (1 ≤ N ≤ 1,000,000)이 주어진다. 둘째 줄에는 N개의 정수를 공백으로 구분해서 주어진다. 모든 정수는 -1,000,000보다 크거나 같고, 1,000,000보다 작거나 같은 정수이다. www.acmicpc.net #include #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); size_t sz; cin >> sz; vector vec; vec.resize(sz); for (size_t i = 0; i > vec[i]; } int min=vec[0], m..
[백준] 10799: 쇠막대기
2020. 12. 29. 05:27
Problem set
10799번: 쇠막대기 여러 개의 쇠막대기를 레이저로 절단하려고 한다. 효율적인 작업을 위해서 쇠막대기를 아래에서 위로 겹쳐 놓고, 레이저를 위에서 수직으로 발사하여 쇠막대기들을 자른다. 쇠막대기와 레이저 www.acmicpc.net #include #include #include using namespace std; int main() { string a; cin >> a; int n = a.size(); stack s; int ans = 0; for (int i=0; i
[백준] 10430: 나머지
2020. 12. 29. 05:26
Problem set
10430번: 나머지 첫째 줄에 A, B, C가 순서대로 주어진다. (2 ≤ A, B, C ≤ 10000) www.acmicpc.net #include using namespace std; auto main()->int { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int a, b, c; cin >> a >> b >> c; cout
[백준] 9613: GCD 합
2020. 12. 29. 05:24
Problem set
9613번: GCD 합 첫째 줄에 테스트 케이스의 개수 t (1 ≤ t ≤ 100)이 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있다. 각 테스트 케이스는 수의 개수 n (1 int { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); unsigned int t = 0; cin >> t; while (t--) { ..
[백준] 9095: 1, 2, 3 더하기
2020. 12. 29. 05:22
Problem set
9095번: 1, 2, 3 더하기 각 테스트 케이스마다, n을 1, 2, 3의 합으로 나타내는 방법의 수를 출력한다. www.acmicpc.net #include using namespace std; int d[11]; void cal() { d[0] = 1; for (int i = 1; i = 1) { d[i] += d[i - 1]; } if (i >= 2) { d[i] += d[i - 2]; } if (i >= 3) { d[i] += d[i - 3]; } } } auto main()->int { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cal(); int t; cin >> t; w..