Problem:
Score : 300 points

Problem Statement

Snuke is making sugar water in a beaker.
Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.

Operation 1: Pour 100A grams of water into the beaker.

Operation 2: Pour 100B grams of water into the beaker.

Operation 3: Put C grams of sugar into the beaker.

Operation 4: Put D grams of sugar into the beaker.

In our experimental environment, E grams of sugar can dissolve into 100 grams of water.

Snuke will make sugar water with the highest possible density.

The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.
Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.
If there is more than one candidate, any of them will be accepted.

We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent.
Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.

Constraints

1 \leq A < B \leq 30

1 \leq C < D \leq 30

1 \leq E \leq 100

100A \leq F \leq 3 000

A, B, C, D, E and F are all integers.

Inputs

Input is given from Standard Input in the following format:

A B C D E F

Outputs

Print two integers separated by a space.
The first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.

Sample Input 1

1 2 10 20 15 200

Sample Output 1

110 10

In this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.

We can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.
It is not possible to make sugar water with higher density.
For example, the following sequences of operations are infeasible:

If we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.

If we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.

Sample Input 2

1 2 1 2 100 1000

Sample Output 2

200 100

There are other acceptable outputs, such as:

400 200

However, the output below is not acceptable:

300 150

This is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.

Sample Input 3

17 19 22 26 55 2802

Sample Output 3

2634 934

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

/*@@@@@@@@@@@@@@@@@@@@O:8:O@@@@@@@@@c cCCCco@@@C  o@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@8:88Cc@@@@@@C.cCCCCCCC:@O.CCCC:c@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@cC888:@@@@o.CCCCCCCCCCc cCCCCCCC:o@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@8:8888cO@o.CCCCCo:CCCCC:cCCCCCCCCCo.@@@@@@@@@@@@@@@Oc
@@@@@@@@@@@@@@@@@@@@oo8888C :CCCCCCc.CCCCC:cCCCCCCCCCCCC.O@@@@@@@@@8c:C88
@@@@@@@@@@@@@@@@@@@@cO8888O:CCCCCCc.CCCCC:cCCCCCCCCCCCCCC:O@@@@@O:cO88888
@@@@@@@@@@@@@@@@@@@@:O88888:oCCCCo.CCCCCc:CCCccCCCCCCCCCCC:C@8:cO88888888
@@@@@@@@@@@@@@@@@@@8c888888ccCCCC.cCCCCo.oCCC::CCCCCCCCCCCC.:O888888888C.
@@@@@@@@@@@@@@@@@@@Oc888888ocCCoc.CCCCC:cCCCoc.oCCCCCCCCc.C8888888888O:c@
@@@@@@@@@@@@@@@@@@8 c888888C:Coo:cCCCCo:CCCoo. oCCCCCCc:O8888888888Oc:@@@
@@@@@@@@@@@@@@@@@:coc888888C:ooo.oCCCC.oCCCoc.:coCCC:c88888888888Oc:8@@@@
@@@@@@@@@@@@@@@C:CCo:888888O:ooo.CCCCc:CCCoo.co.oo:c88888888888Oc.8@@@@@@
@@@@@@@@@@@@@@:oCCCC:O88888O:oo..CCCC.oCCCoc.CC..c8888888888OCc..@@@@@@@@
@@@@@@@@@@@@O.CCCC.. O888888:c.c:CCCc:CCCoo:cC::8888888888OCc.oCcc@@@@@@@
@@@@@@@@@@@C:CCCCco8oc888888.:C:cCCC.oCCCooc .O888888888Oo..CCCCC:O@@@@@@
@@@@@@@@@@ccCCCCCc:8O:O88888:.cooCo.oCCCCoo.C888888888o.cO8c:CCCCo:@@@@@@
@@@@@@@@@:cCCCCCCC.C8oo88888:oCCCc:CCCCCo::888888888C:88Oo.cCCCCCCcc@@@@@
@@@@@@@@:oCCCCCCCCc.O8888888:oCCo:CCCCCo.C88888888888OCc.cCCCCCCCCC:C@@@@
@@@@@@@:cCCCCCCCCooc.O88888O:CCCCCCCCCc:88888888888Oo:.oCCCCCCCCCCCo.:O@@
@@@@@@ccCCCCCCCooooo. oO888C:CCCCCCCC:o88888888OOC:. ooooCCCCCCCCCCC:oO:8
@@@@@ocCCCCCCCooooc.oo cCCC:cCCCCCCC.C88888OOCo: c88o.oooCCCCCCCCCCCC:O8o
@@@@C:CCCCCCCoooo.:OO:oo.::.CCCCCCCc:OOOCCoc:.cCco888o:oooCCCCCCCCCCCcc88
@@@8.CCCCCCCCoo::O88C ..oCCCCCCCCCCCc.:::coCCCCCo:8888o.ooooCCCCCCCCCC:O8
@@@:oCCCCCCCoc.C8888o ..:CCCCCCCCCCCCCCCCc .: cCo.O8888o.oooCCCCCCCCCCcc8
@@C:CCCCCCCo.o888888o . :CCCCCCCCCCCCCCC. co c.co.o88888C.ooooCCCCCCCCo:O
@8.oCCCCCC:o88888888C   :CCCCCCCCCCCCCC:     c.:o::O88888O.ooooCCCCCCCC:o
::cCCCCC.c88888888888:coCCCCCCCCCCCCCCC   :.cc.ooc.O888888O:coooCCCCCCCcc
8:oCCc.o88888888888888:oCCoCCCCCCCCCCCo.    .:oooo.oO8888888c:ooooCCCCCo:
8o..cO88888888888888888o::..oooooooooooooooooooo:cccC88888888C.oooooCCCC:
8888888888888888888888888c..cooooooo:oooooooc:cO@@O:CO888888888::ooooooC:
88888888888888888888888OCoCCC::ccc..:::....8@@@@@@@:oCO888888888C.cooooo:
888888888888888888888OCCCCo:::cccC@@8.:cco:@@@@@@@@C:CC88888888888O::coc.
888888888888888888OC::cc..c8888888OooooO8o.C@@@@@@@@:ooO8888888888888OOO8
888888888888888OOCcc88O:C:cc:C8888c CccC:o8O:ccoO@@@ccCoO8888888888888888
888888888888OCooCo:888:c.oCcco:O8:oo:Cc:o.C888888oc@8:CooO888888888888888
8888888OOCooCCoCCc:888C.:oo:co:CO:oo:oo.cO8888888Ooc@ccCCoO88888888888888
CCCCoooCCCCCCCCo:oCO8888c:oc::C88C.:oooO8888888OCoC:88:CCCoC88888888888*/

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> T dup(T a,T b){return (a+b-1)/b;}

#define mod 1000000007LL
#define INF 10000000000000000

#define rep(i, n) for(int i = 0;i < n;++i)
#define rep1(i, n) for(int i = 1;i <= n;++i)
#define rrep(i, n) for(int i = (n-1);i >= 0;--i)
#define rrep1(i, n) for(int i = n;i > 0;--i)

#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"

#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, n, sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL<<(n))
int f;
int o(int a,int b){
    if (a*100+b>f) return -1;
    return 100*b/(a*100+b);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------

    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e >> f;
    int q[f/100+1][f+1];
    m(q,-1);
pri2(0,0);
//    q[0][0]=0;
//
//    rep(i,f/100+1){
//        rep(j,f){
//            if(i*100+j>f) break;
//            if(q[i][j]!=-1){
//                if(i+a<=f/100)q[i+a][j]=o(i+a,j);
//                if(i+b<=f/100)q[i+b][j]=o(i+b,j);
//                if(j+c<=f)q[i][j+c]=o(i,j+c);
//                if(j+d<=f)q[i][j+d]=o(i,j+d);
//            }
//        }
//    }
//    int ans = 0;
//    int ansi =0;
//    int ansj =0;
//    rep(i,f/100+1){
//        rep(j,f){
//            if(i*100+j>f) break;
//            if(ans<=q[i][j]&&i*e>=j){
//                ansi = i;
//                ansj = j;
//                ans = q[i][j];
//            }
//        }
//    }
//    ansi = ansi * 100 + ansj;
//    pri2(ansi,ansj);
//
    return 0;
}