Skip to content

Commit d6803a0

Browse files
committed
solved 1108B
1 parent 2205a9d commit d6803a0

File tree

10 files changed

+251
-0
lines changed

10 files changed

+251
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"mainSolution": {
3+
"value": "/Users/dipta007/my-world/gdrive/Programming/Contest-LIFE/@SITES/acmx/Codeforces - Codeforces Round #535 (Div. 3)/B. Divisors of Two Integers/template.cpp"
4+
},
5+
"bruteSolution": {},
6+
"generator": {},
7+
"checker": {},
8+
"companionConfig": {
9+
"value": {
10+
"name": "B. Divisors of Two Integers",
11+
"group": "Codeforces - Codeforces Round #535 (Div. 3)",
12+
"url": "https://codeforces.com/problemset/problem/1108/B",
13+
"memoryLimit": 256,
14+
"timeLimit": 1000
15+
}
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>English</string>
7+
<key>CFBundleIdentifier</key>
8+
<string>com.apple.xcode.dsym.sol</string>
9+
<key>CFBundleInfoDictionaryVersion</key>
10+
<string>6.0</string>
11+
<key>CFBundlePackageType</key>
12+
<string>dSYM</string>
13+
<key>CFBundleSignature</key>
14+
<string>????</string>
15+
<key>CFBundleShortVersionString</key>
16+
<string>1.0</string>
17+
<key>CFBundleVersion</key>
18+
<string>1</string>
19+
</dict>
20+
</plist>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/Users/dipta007/my-world/gdrive/Programming/Contest-LIFE/@SITES/acmx/Codeforces - Codeforces Round #535 (Div. 3)/B. Divisors of Two Integers/template.cpp:167:40: error: expected ';' after expression
2+
flg = 0
3+
 ^
4+
 ;
5+
/Users/dipta007/my-world/gdrive/Programming/Contest-LIFE/@SITES/acmx/Codeforces - Codeforces Round #535 (Div. 3)/B. Divisors of Two Integers/template.cpp:171:38: warning: & has lower precedence than ==; == will be evaluated first [-Wparentheses]
6+
} else if (y & p.ss == 0) {
7+
 ^~~~~~~~~~~
8+
/Users/dipta007/my-world/gdrive/Programming/Contest-LIFE/@SITES/acmx/Codeforces - Codeforces Round #535 (Div. 3)/B. Divisors of Two Integers/template.cpp:171:38: note: place parentheses around the '==' expression to silence this warning
9+
} else if (y & p.ss == 0) {
10+
 ^
11+
 ( )
12+
/Users/dipta007/my-world/gdrive/Programming/Contest-LIFE/@SITES/acmx/Codeforces - Codeforces Round #535 (Div. 3)/B. Divisors of Two Integers/template.cpp:171:38: note: place parentheses around the & expression to evaluate it first
13+
} else if (y & p.ss == 0) {
14+
 ~~^~~~~~
15+
1 warning and 1 error generated.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6eb910277293941a5785aa8613c71c0b
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
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+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20 8
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
10
2+
10 2 8 1 2 4 1 20 4 5
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8 20

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy