Group/EDOC
EDOC 2024-1 8회차 과제 (기하 알아보기)
jungh150c
2024. 6. 2. 15:43
A. 네 번째 점 (백준 3009번)

https://www.acmicpc.net/problem/3009
//C++
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
vector<int> x = vector<int>(3);
vector<int> y = vector<int>(3);
for (int i = 0; i < 3; i++) {
cin >> x[i] >> y[i];
}
sort(x.begin(), x.end());
sort(y.begin(), y.end());
int ansx, ansy;
if (x[1] == x[0]) ansx = x[2];
else ansx = x[0];
if (y[1] == y[0]) ansy = y[2];
else ansy = y[0];
cout << ansx << ' ' << ansy << '\n';
}
(정답)
B. 참외밭 (백준 2477번)

https://www.acmicpc.net/problem/2477
//C++
#include <iostream>
#include <vector>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int k;
cin >> k;
int ans = 0;
vector<vector<int>> data = vector<vector<int>>(6, vector<int>(2));
vector<int> cnt = vector<int>(5, 0);
for (int i = 0; i < 6; i++) {
cin >> data[i][0] >> data[i][1];
cnt[data[i][0]]++;
}
int cur = 0;
int nxt = 0;
while (true) {
nxt = (cur + 1) % 6;
if (cnt[data[cur][0]] == 1 && cnt[data[nxt][0]] == 1) {
ans += data[cur][1] * data[nxt][1];
cur = (nxt + 2) % 6;
nxt = (cur + 1) % 6;
ans -= data[cur][1] * data[nxt][1];
break;
}
cur++;
}
cout << ans * k << '\n';
}
(정답)