[C++] SWEA 7829. 보물왕 태혁

멋진감자·2025년 3월 21일
0

알고리즘

목록 보기
115/120
post-thumbnail

🌽 문제

🥕 입출력

🥔 풀이

입력받은 n개의 약수들 중 가장 작은 수와 가장 큰 수의 곱을 출력한다.
약수의 성질이 그렇다.

🥬 코드

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int t, n;
	cin >> t;
	for (int i = 1; i <= t; i++) {
		cout << "#" << i << " ";
		cin >> n;
		vector<int> v(n);
		for (int j = 0; j < n; j++) cin >> v[j];
		sort(v.begin(), v.end());
		cout << v[0] * v[n - 1] << "\n";
	}

	return 0;
}

🥜 채점

난이도가 왜이래

profile
난멋져

0개의 댓글

Powered by GraphCDN, the GraphQL CDN