Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1LL << 60;

double A, B, C, D, E, F;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
    cin >> A >> B >> C >> D >> E >> F;

    double water_total = 0;  
    double sugar_total = 0;  
    double percent = 0;
    int max_v = 3000;
    for (int a = 0; a <= max_v; a += A * 100) {
        for (int b = 0; b <= max_v; b += B * 100) {
            for (int c = 0; c <= max_v; c += C) {
                for (int d = 0; d <= max_v; d += D) {
                    double water = a + b;
                    double sugar = c + d;
                    if (water + sugar > F) break;

                    ll g = gcd((ll)100 * sugar, (ll)E);
                    double need_water = (100 * sugar / g) / (E / g);
                    if (sugar == 0) continue;

                    if (water >= need_water) {
                        // cout << sugar << " " << (sugar + water) << endl;
                        double tmp = sugar / (sugar + water);
                        if (percent < tmp) {
                            water_total = water;
                            sugar_total = sugar;
                            percent = tmp; 
                        }
                    }
                }
            }
        }
    } 

    cout << water_total + sugar_total << " " << sugar_total << endl;
}

Compiler output:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:58,
                 from a.cc:1:
/usr/include/c++/14/numeric: In instantiation of 'constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn) [with _Mn = double; _Nn = long long int; common_type_t<_Mn, _Nn> = double]':
a.cc:28:31:   required from here
   28 |                     ll g = gcd((ll)100 * sugar, (ll)E);
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/numeric:175:21: error: static assertion failed: std::gcd arguments must be integers
  175 |       static_assert(is_integral_v<_Mn> && is_integral_v<_Nn>,
      |                     ^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/numeric:175:21: note: 'std::is_integral_v<double>' evaluates to false
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/type_traits: In instantiation of 'struct std::make_unsigned<double>':
/usr/include/c++/14/type_traits:2076:11:   required by substitution of 'template<class _Tp> using std::make_unsigned_t = typename std::make_unsigned::type [with _Tp = double]'
 2076 |     using make_unsigned_t = typename make_unsigned<_Tp>::type;
      |           ^~~~~~~~~~~~~~~
/usr/include/c++/14/numeric:182:24:   required from 'constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn) [with _Mn = double; _Nn = long long int; common_type_t<_Mn, _Nn> = double]'
  182 |       return __detail::__gcd<make_unsigned_t<_Ct>>(__m2, __n2);
      |              ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:28:31:   required from here
   28 |                     ll g = gcd((ll)100 * sugar, (ll)E);
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/type_traits:1929:13: error: invalid use of incomplete type 'class std::__make_unsigned_selector<double, false, false>'
 1929 |     { using type = typename __make_unsigned_selector<_Tp>::__type; };
      |             ^~~~
/usr/include/c++/14/type_traits:1837:11: note: declaration of 'class std::__make_unsigned_selector<double, false, false>'
 1837 |     class __make_unsigned_selector;
      |           ^~~~~~~~~~~~~~~~~~~~~~~~