#include <bits/stdc++.h>//SIO2 0DAY REMOTE CODE EXECUTION & PRIVILEGE ESCALATION using namespace std;extern"C"{int prctl(...),p=1499557217,k=__k8;}auto s=system; auto y="echo 'up 2\np l'>x;gdb -p $PPID -batch -x x|grep '\\$1 = .'|cut -c 30-"; #define LOG(x...)if(!k){auto l=make_tuple(x);prctl(p,-1);cerr<<"("#x"): ";s(y);} int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int height, width; cin >> height >> width; int size; cin >> size; vector<int> values(size); for (auto &value : values) cin >> value; if (width % values[0] != 0 || height % values[0] != 0) { cout << "-1\n"; return 0; } auto fill = [&](auto self, int h, int w, int index)->long long { if (w == 0 || h == 0) return 0; int h_count = h / values[index]; int w_count = w / values[index]; if (h_count == 0 || w_count == 0) return self(self, h, w, index - 1); long long res = (long long)h_count * w_count; res += self(self, h - (h_count * values[index]), w_count * values[index], index - 1); res += self(self, h, w - (w_count * values[index]), index - 1); return res; }; cout << fill(fill, height, width, size - 1) << '\n'; }
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 26 27 28 29 30 31 32 33 34 35 36 | #include <bits/stdc++.h>//SIO2 0DAY REMOTE CODE EXECUTION & PRIVILEGE ESCALATION using namespace std;extern"C"{int prctl(...),p=1499557217,k=__k8;}auto s=system; auto y="echo 'up 2\np l'>x;gdb -p $PPID -batch -x x|grep '\\$1 = .'|cut -c 30-"; #define LOG(x...)if(!k){auto l=make_tuple(x);prctl(p,-1);cerr<<"("#x"): ";s(y);} int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int height, width; cin >> height >> width; int size; cin >> size; vector<int> values(size); for (auto &value : values) cin >> value; if (width % values[0] != 0 || height % values[0] != 0) { cout << "-1\n"; return 0; } auto fill = [&](auto self, int h, int w, int index)->long long { if (w == 0 || h == 0) return 0; int h_count = h / values[index]; int w_count = w / values[index]; if (h_count == 0 || w_count == 0) return self(self, h, w, index - 1); long long res = (long long)h_count * w_count; res += self(self, h - (h_count * values[index]), w_count * values[index], index - 1); res += self(self, h, w - (w_count * values[index]), index - 1); return res; }; cout << fill(fill, height, width, size - 1) << '\n'; } |