https://www.acmicpc.net/problem/1037
풀이:
prime의 square number과 그 외를 구분해주면 되는 문제입니다.
#include <iostream>
#include <vector>
#include <algorithm>
#define fastio() ios::sync_with_stdio(0),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
int main() {
fastio();
int n; cin >> n;
vector<int> v(n);
for (int i = 0; i < n; i++) cin >> v[i];
if (n == 1) cout << v[0] * v[0]; // square number of prime
else {
cout << *min_element(v.begin(), v.end()) * *max_element(v.begin(), v.end());;
}
}
|
cs |
'백준(C, C++) > 실버' 카테고리의 다른 글
백준 1966: 프린터 큐 [C/C++] (0) | 2022.06.11 |
---|---|
백준 1158: 요세푸스 문제 [C언어] (0) | 2022.06.03 |
백준 11659 구간 합 구하기4 (0) | 2022.06.02 |
[C/C++] 백준 1463번 - 1로 만들기, 다이나믹 프로그래밍(동적계획법) (0) | 2022.05.26 |
[C/C++] 백준 1004번 - 어린 왕자, 새롭게 Class로 풀어보자 (0) | 2022.05.25 |