From b3c5de0ceaa1499c31516c68ccc8e9fc109fae59 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Wed, 30 Dec 2020 18:39:46 +0800 Subject: [PATCH] =?UTF-8?q?P5682=20[CSP-J2019=20=E6=B1=9F=E8=A5=BF]=20?= =?UTF-8?q?=E6=AC=A1=E5=A4=A7=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R44430393 --- problem/P5682/P5682.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 problem/P5682/P5682.cpp diff --git a/problem/P5682/P5682.cpp b/problem/P5682/P5682.cpp new file mode 100644 index 00000000..3885fdfe --- /dev/null +++ b/problem/P5682/P5682.cpp @@ -0,0 +1,25 @@ +#include + +using namespace std; + +int n, t, a[200005]; + +int main() { + set s; + cin >> n; + for (int i = 0; i < n; i++) { + cin >> t; + s.insert(t); + } + if (s.size() <= 1) { + cout << -1 << endl; + } + else { + t = 0; + for (int i : s) { + a[++t] = i; + } + cout << max(a[t - 2], a[t] % a[t - 1]) << endl; + } + return 0; +}