Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		if buf[0] == "0" {
			break
		}
		q1, _ := strconv.Atoi(buf[0]) // 買うべき鶏肉の量の下限(g)
		b, _ := strconv.Atoi(buf[1])  // 予算
		c1, _ := strconv.Atoi(buf[2]) // 会津地鶏の値段(/100g)
		c2, _ := strconv.Atoi(buf[3]) // 普通の鶏肉の値段(/100g)
		q2, _ := strconv.Atoi(buf[4]) // 会津地鶏の買える量の上限(g)
		maxAizuChiken := min(b/c1, q2)
		if maxAizuChiken <= 0 {
			fmt.Println("NA")
			continue
		}
		if c2 >= c1 {
			maxNormalChiken := (b - maxAizuChiken*c1) / c2
			if maxAizuChiken+maxNormalChiken < q1 { // 買い切ったけども必要な鶏肉の下限に達しなかった
				fmt.Println("NA")
			} else {
				fmt.Println(maxAizuChiken, maxNormalChiken)
			}
			continue
		}
		if (b-c1)/c2+1 < q1 { // 会津地鶏を1単位+普通の鶏肉を予算目一杯買ったが買うべき下限を超えなかった
			fmt.Println("NA")
			continue
		}
		// 二分探索
		low, high := 0, maxAizuChiken+1
		for high-low > 1 {
			mid := (low + high) / 2
			if check(mid, b, c1, c2, q1) {
				low = mid
			} else {
				high = mid
			}
		}
		fmt.Println(low, (b-low*c1)/c2)
	}
}

func check(mid, b, c1, c2, q1 int) bool {
	if mid+(b-mid*c1)/c2 < q1 {
		return false
	}
	return true
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

C++: #include<iostream>
using namespace std;
int main(){
long q1,b,c1,c2,q2,p1,p2,qq;
while(cin>>q1){
if(q1==0)break;
cin>>b>>c1>>c2>>q2;
p1=p2=0;

for(;p2<q1;){
if(b<c2){cout<<"NA"<<endl;goto E;}
b-=c2;p2++;
}
if(q1>=q2){
for(;p1<q2;){
if(b<c1-c2)break;
b-=(c1-c2);p1++;p2--;
}
}else{
for(;p1<q1;){
if(b<c1-c2)break;
b-=(c1-c2);p1++;p2--;
}
for(;p1<q2;){
if(b<c1)break;
b-=c1;p1++;
}
}
for(;;){
if(b<c2)break;
b-=c2;p2++;
}
if(p1>0)cout<<p1<<" "<<p2<<endl;
else cout<<"NA"<<endl;
E:;
}
return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int q1,b,c1,c2,q2;
	while(cin >> q1 , q1){
		cin >> b >> c1 >> c2 >> q2;
		int now = q2 * c1;
		while(now>b){
			now -= c1;
			q2--;
		}
		while(q2+(b-now)/c2 < q1 && q2 > 0){
			now -= c1;
			q2--;
		}
		if(q2>0){
			cout << q2 << " " << (b-now)/c2 << endl;
		}else{
			cout << "NA" << endl;
		}
	}
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	Int q1,b,c1,c2,q2;
	while(q1=in()){
		cin>>b>>c1>>c2>>q2;
		if(b<c1+c2*(q1-1)){
			cout<<"NA"<<endl;
			continue;
		}
		b-=c1;q1--;q2--;
		Int t;
		if(c1>c2){
			t=(b-c2*q1)/(c1-c2);
			if(t>q1)t=b/c1;
			chmin(t,q2);
		}else{
			t=b/c2;
			chmin(t,q2);
		}
		cout<<t+1<<" "<<(b-c1*t)/c2<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

#define ll long long

int main(){
    ll q1;
    
    while(cin >> q1 && q1){
        ll badget, pi, pn, lim;
        ll reti, retn;
        cin >> badget >> pi >> pn >> lim;
        
        if(pi*q1 <= badget){
            reti = q1;
            retn = 0;
        }else{
            retn = ceil((double)(pi*q1 - badget) / (pi - pn));
            reti = q1 - retn;
        }

        badget -= pi * reti + pn * retn;

        if(reti > lim){
            badget += pi * (reti - lim);
            reti = lim;
        }else{
            if(badget > 0){
                reti += min(lim - reti, badget / pi);
                badget -= min(lim - reti, badget / pi) * pi;
            }
        }

        if(badget > 0){
            retn += badget / pn;
            badget = badget - (badget / pn) * pn;
        }
        if(badget < 0 || retn+reti < q1 || retn < 0 || reti <= 0){
            cout << "NA" << endl;
        }else{
            cout << reti << " " << retn << endl;
        }
    }
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 20000
#define MAX_M 16

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int q1, b, c1, c2, q2;
P ans;

int main(){
	while (cin >> q1&&q1){
		cin >> b >> c1 >> c2 >> q2;
		bool f = 0;
		ans = P(-1, -1);
		if (c2 < c1){
			FOR(i, 1, q2 + 1){
				if (q1 - i >= 0){
					if (i*c1 + (q1 - i)*c2 <= b){
						int co = (b - i*c1) / c2;
						if (ans.first < i&&co >= 0){
							f = 1;
							ans = P(i, co);
						}
					}
				}
				else{
					if (i*c1 <= b){
						if (ans.first < i){
							f = 1;
							ans = P(i, 0);
						}
					}
				}
			}
			if (f)cout << ans.first << " " << ans.second << endl;
			else cout << "NA" << endl;
		}
		else{
			ans = P(0, 0);
			REP(i, q2){
				if (b - c2 > 0){
					b -= c2;
					ans.first++;
				}
			}
			while (b - c1 > 0){
				b -= c1;
				ans.second++;
			}
			if (ans.first + ans.second <= q1)cout << "NA" << endl;
			else cout << ans.first << " " << ans.second << endl;
		}
	}
}

C++: #include <iostream>
#include <utility>
using namespace std;

int q1,b,c1,c2,q2;

// ????´\?¶???????????????????x??¨??????
bool C(int x){
    if(x*c1 > b || x > q2)
        return false;

    return x + (b-x*c1)/c2 >= q1;
}

int main(){
    while(1){
        cin>>q1;
        if(!q1)break;
        cin>>b>>c1>>c2>>q2;
        
        int lb = 0, ub = 1e+9;
        for(int i=0;i<100;i++){
            int mid = (lb + ub) / 2;
            if(C(mid)) lb = mid;
            else ub = mid;
        }

        if(lb == 0)
            cout<<"NA"<<endl;
        else
            cout<<lb<<" "<<(b-lb*c1)/c2<<endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
double  q1,b,q2,ans;
int A,B;
double c1,c2;
int L,R,M;
void calcB(){
  int money = b-A*c1;
  if(money>0)B=money/c2;
  else B=-99999;
}

  
bool check(int x){
  A=x;
  calcB();
  if(B>=0&&A+B>=q1)return true;
  else return false;
}

int main(){
  while(cin>>q1){
    ans=-1;
    if(q1==0)break;
    cin>>b>>c1>>c2>>q2;

    L=1;
    R=q2;
    M=(L+R)/2;

    while(L<R){
      if(check(M)&&!check(M+1)){
	break;
      }else if(check(M)){
	L=M+1;
	M=(L+R)/2;
      }else{
	R=M;
	M=(L+R)/2;
      }
	
    }

    //cout<<A<<' '<<B<<endl;
    if(check(M)){
      A=M;
      calcB();
      cout<<M<<' '<<B<<endl;
    } else cout<<"NA"<<endl;
    
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
 
int main(){
	int q1,b,c1,c2,q2,now;
 
	while(cin >> q1 && q1){
 
		cin >> b >> c1 >> c2 >> q2;
 
		/*ツ全ツづ地ツ鶏ツづ可シツ津ィ*/
		now = q2*c1;
 
		/*ツ必ツ要ツ湘ーツ個渉づーツ鳴楪つスツつキツづヲツつ、ツづ可地ツ鶏ツづ個青板づーツ陳イツ静淞つオツづつ「ツつュ*/
		while(now>b){
			now -= c1;
			q2--;
		}
 
		while(q2+(b-now)/c2 < q1){
			now -= c1;
			q2--;
		}
 
		if(q2>0){
			cout << q2 << " " << (b-now)/c2 << endl;
		}else{
			cout << "NA" << endl;
		}
	}
}