|
| 1 | +#include <algorithm> |
| 2 | +#include <bitset> |
| 3 | +#include <cassert> |
| 4 | +#include <cctype> |
| 5 | +#include <climits> |
| 6 | +#include <cmath> |
| 7 | +#include <cstdio> |
| 8 | +#include <cstdlib> |
| 9 | +#include <cstring> |
| 10 | +#include <fstream> |
| 11 | +#include <iostream> |
| 12 | +#include <iomanip> |
| 13 | +#include <iterator> |
| 14 | +#include <list> |
| 15 | +#include <map> |
| 16 | +#include <numeric> |
| 17 | +#include <queue> |
| 18 | +#include <set> |
| 19 | +#include <sstream> |
| 20 | +#include <stack> |
| 21 | +#include <string> |
| 22 | +#include <utility> |
| 23 | +#include <vector> |
| 24 | +// #include <bits/stdc++.h> |
| 25 | +using namespace std; |
| 26 | + |
| 27 | +//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector") |
| 28 | +//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") |
| 29 | + |
| 30 | +#define READ(f) freopen(f, "r", stdin) |
| 31 | +#define WRITE(f) freopen(f, "w", stdout) |
| 32 | +#define MP(x, y) make_pair(x, y) |
| 33 | +#define PB(x) push_back(x) |
| 34 | +#define FOR(i, L, R) for (int i = (int)(L); i <= (int)(R); i++) |
| 35 | +#define ROF(i, L, R) for (int i = (int)(L); i >= (int)(R); i--) |
| 36 | +#define ALL(p) p.begin(), p.end() |
| 37 | +#define ALLR(p) p.rbegin(), p.rend() |
| 38 | +#define SET(p) memset(p, -1, sizeof(p)) |
| 39 | +#define CLR(p) memset(p, 0, sizeof(p)) |
| 40 | +#define getI(a) scanf("%d", &a) |
| 41 | +#define getII(a, b) scanf("%d%d", &a, &b) |
| 42 | +#define getIII(a, b, c) scanf("%d%d%d", &a, &b, &c) |
| 43 | +#define getL(a) scanf("%lld", &a) |
| 44 | +#define getLL(a, b) scanf("%lld%lld", &a, &b) |
| 45 | +#define getLLL(a, b, c) scanf("%lld%lld%lld", &a, &b, &c) |
| 46 | +#define getF(n) scanf("%lf", &n) |
| 47 | +#define bitCheck(N, in) ((bool)(N & (1 << (in)))) |
| 48 | +#define bitOn(N, in) (N | (1 << (in))) |
| 49 | +#define bitOff(N, in) (N & (~(1 << (in)))) |
| 50 | +#define bitFlip(a, k) (a ^ (1 << (k))) |
| 51 | +#define bitCount(a) __builtin_popcount(a) |
| 52 | +#define bitCountLL(a) __builtin_popcountll(a) |
| 53 | +#define bitLeftMost(a) (63 - __builtin_clzll((a))) |
| 54 | +#define bitRightMost(a) (__builtin_ctzll(a)) |
| 55 | +#define ranL(a, b) ((((rand() << 15) ^ rand()) % ((b) - (a) + 1)) + (a)) |
| 56 | +#define ranI(a, b) ((((ll)rand() * rand()) % ((b) - (a) + 1)) + (a)) |
| 57 | +#define ranF(a, b) (((double)rand() / RAND_MAX) * ((b) - (a)) + (a)) |
| 58 | +#define UNIQUE(V) (V).erase(unique((V).begin(), (V).end()), (V).end()) |
| 59 | +#define SETI(ar) memset(ar, 126, sizeof ar) |
| 60 | + |
| 61 | +#define printbits(x, n) cout << #x << " = " << x << " = " << bitset<n>(x) << endl /// Least significant n bits of x, n must be constant |
| 62 | +#define tobinary(x) string(bitset<64>(x).to_string<char, string::traits_type, string::allocator_type>()).substr(min(63, __builtin_clzll(x)), 64) |
| 63 | +#define lastbits(x, n) cout << string(bitset<64>(x).to_string<char, string::traits_type, string::allocator_type>()).substr(64 - n, 64) << endl |
| 64 | +#define firstbits(x, n) cout << string(bitset<64>(x).to_string<char, string::traits_type, string::allocator_type>()).substr(min(63, __builtin_clzll(x)), 64).substr(0, n) << endl; |
| 65 | + |
| 66 | +#define ff first |
| 67 | +#define ss second |
| 68 | +#define sf scanf |
| 69 | +#define pf printf |
| 70 | + |
| 71 | +typedef long long ll; |
| 72 | +typedef unsigned long long ull; |
| 73 | +typedef vector<int> vi; |
| 74 | +typedef vector<vi> vii; |
| 75 | +typedef pair<int, int> pii; |
| 76 | +#define FMT(...) (sprintf(CRTBUFF, __VA_ARGS__) ? CRTBUFF : 0) |
| 77 | +char CRTBUFF[30000]; |
| 78 | + |
| 79 | +#ifdef dipta007 |
| 80 | +#define debug(args...) \ |
| 81 | + { \ |
| 82 | + cerr << __LINE__ << " D: "; \ |
| 83 | + dbg, args; \ |
| 84 | + cerr << endl; \ |
| 85 | + } |
| 86 | +#define trace(...) \ |
| 87 | + { \ |
| 88 | + cerr << "Line " << __LINE__ << ": "; \ |
| 89 | + __f(#__VA_ARGS__, __VA_ARGS__); \ |
| 90 | + } |
| 91 | +template <typename Arg1> |
| 92 | +void __f(const char *name, Arg1 &&arg1) |
| 93 | +{ |
| 94 | + cerr << name << " : " << arg1 << std::endl; |
| 95 | +} |
| 96 | +template <typename Arg1, typename... Args> |
| 97 | +void __f(const char *names, Arg1 &&arg1, Args &&... args) |
| 98 | +{ |
| 99 | + const char *comma = strchr(names + 1, ','); |
| 100 | + cerr.write(names, comma - names) << " : " << arg1 << " | "; |
| 101 | + __f(comma + 1, args...); |
| 102 | +} |
| 103 | +#else |
| 104 | +#define debug(args...) /// Just strip off all debug tokens |
| 105 | +#define trace(...) ///yeeeee |
| 106 | +#endif |
| 107 | + |
| 108 | +struct debugger |
| 109 | +{ |
| 110 | + template <typename T> |
| 111 | + debugger &operator,(const T &v) |
| 112 | + { |
| 113 | + cerr << v << " "; |
| 114 | + return *this; |
| 115 | + } |
| 116 | +} dbg; |
| 117 | + |
| 118 | +const double EPS = 1e-9; |
| 119 | +const int INF = 0x3f3f3f3f; |
| 120 | +const double PI = 2.0 * acos(0.0); |
| 121 | + |
| 122 | +ll MIN() { return INF; } |
| 123 | +template <typename T, typename... Args> |
| 124 | +inline T MIN(T a, Args... args) { return min(a, (T)MIN(args...)); } |
| 125 | + |
| 126 | +ll MAX() { return -INF; } |
| 127 | +template <typename T, typename... Args> |
| 128 | +inline T MAX(T a, Args... args) { return max(a, (T)MAX(args...)); } |
| 129 | + |
| 130 | +// g++ -g -O2 -std=gnu++11 A.cpp |
| 131 | +// ./a.out |
| 132 | + |
| 133 | +///****************** template ends here **************** |
| 134 | + |
| 135 | +int main() |
| 136 | +{ |
| 137 | +#ifdef dipta007 |
| 138 | + //READ("in.txt"); |
| 139 | + //WRITE("out.txt"); |
| 140 | +#endif // dipta007 |
| 141 | + ios_base::sync_with_stdio(0);cin.tie(0); |
| 142 | + |
| 143 | + int n; |
| 144 | + while (cin >> n) { |
| 145 | + vi v(n); |
| 146 | + for (auto &x: v) { |
| 147 | + cin >> x; |
| 148 | + } |
| 149 | + sort(ALL(v)); |
| 150 | + |
| 151 | + int rx = -1, ry = -1; |
| 152 | + FOR(i, 0, n-1) { |
| 153 | + FOR(j, 0, n-1) { |
| 154 | + if (i != j) { |
| 155 | + map <int, int> mp; |
| 156 | + int x = v[i], y = v[j]; |
| 157 | + for(auto vv: v) { |
| 158 | + mp[vv] += 1; |
| 159 | + } |
| 160 | + |
| 161 | + int flg = 1; |
| 162 | + for(auto p: mp) { |
| 163 | + // if (x == 4 && y == 4) |
| 164 | + // cout << p.ff << " " << p.ss << endl; |
| 165 | + if (p.ss == 2) { |
| 166 | + if (x >= p.ff && y >= p.ff && x % p.ff == 0 && y % p.ff == 0) { |
| 167 | + |
| 168 | + } else { |
| 169 | + flg = 0; |
| 170 | + } |
| 171 | + } else if (x >= p.ff && x % p.ff == 0) { |
| 172 | + |
| 173 | + } else if (y >= p.ff && y % p.ff == 0) { |
| 174 | + |
| 175 | + } else { |
| 176 | + flg = 0; |
| 177 | + } |
| 178 | + } |
| 179 | + if (flg == 1) { |
| 180 | + rx = x, ry = y; |
| 181 | + break; |
| 182 | + } |
| 183 | + } |
| 184 | + } |
| 185 | + if (rx != -1) { |
| 186 | + break; |
| 187 | + } |
| 188 | + } |
| 189 | + |
| 190 | + cout << rx << " " << ry << endl; |
| 191 | + } |
| 192 | + |
| 193 | + return 0; |
| 194 | +} |
0 commit comments