#include <bits/stdc++.h> using namespace std; using ull = unsigned long long; using uint = unsigned int; using ll = long long; #define loop(i, a, b) for(int i = a; i <= b; i++) #define loop_rev(i, a, b) for(int i = a; i >= b; i--) #define all(x) x.begin(), x.end() #define sz(x) int(x.size()) #define pb push_back vector<int> v; int main() { cin.tie(0)->sync_with_stdio(0); int n, m, k; cin>>n>>m>>k; loop(i, 1, k) { int a; cin>>a; v.pb(a); } sort(all(v)); int mini=v[0]; if(n%mini!=0 or m%mini!=0)cout<<-1; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #include <bits/stdc++.h> using namespace std; using ull = unsigned long long; using uint = unsigned int; using ll = long long; #define loop(i, a, b) for(int i = a; i <= b; i++) #define loop_rev(i, a, b) for(int i = a; i >= b; i--) #define all(x) x.begin(), x.end() #define sz(x) int(x.size()) #define pb push_back vector<int> v; int main() { cin.tie(0)->sync_with_stdio(0); int n, m, k; cin>>n>>m>>k; loop(i, 1, k) { int a; cin>>a; v.pb(a); } sort(all(v)); int mini=v[0]; if(n%mini!=0 or m%mini!=0)cout<<-1; } |