Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define int long long
- using namespace std;
- signed main() {
- ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
- int num_tests;
- cin >> num_tests;
- while (num_tests--) {
- int a, b, c, target;
- cin >> a >> b >> c;
- vector<int> dims = {a, b, c};
- sort(dims.begin(), dims.end());
- cin >> target;
- set<tuple<int, int, int>> possible_triples, adjusted_triples;
- for (int i = 1; i <= a; ++i) {
- for (int j = 1; j <= b; ++j) {
- if (target % i == 0 && (target / i) % j == 0) {
- int k = (target / i) / j;
- if (k <= c) {
- possible_triples.insert(make_tuple(i, j, k));
- }
- }
- }
- }
- for (const auto& triplet : possible_triples) {
- vector<int> values = {get<0>(triplet), get<1>(triplet), get<2>(triplet)};
- sort(values.begin(), values.end());
- adjusted_triples.insert(make_tuple(dims[0] - values[0], dims[1] - values[1], dims[2] - values[2]));
- }
- int max_volume = 0;
- for (const auto& triplet : adjusted_triples) {
- int dx = get<0>(triplet), dy = get<1>(triplet), dz = get<2>(triplet);
- if (dx >= 0 && dy >= 0 && dz >= 0) {
- int volume = (dx + 1) * (dy + 1) * (dz + 1);
- max_volume = max(max_volume, volume);
- }
- }
- cout << max_volume << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement