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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back

ll q1,b,c1,c2,q2;

main(){
  while(cin>>q1,q1){
    cin>>b>>c1>>c2>>q2;

    if(c1<=c2){
      ll aizu=b/c1,n=0;
      b-=aizu*c1;
      if(aizu>q2){
        b+=(aizu-q2)*c1;
        aizu=q2;
        n=b/c2;
      }
      if(aizu+n<q1 || aizu<1){
        puts("NA");
        goto END;
      }
      cout<<aizu<<" "<<n;
    }else{
      if(b<c1){
        puts("NA");
        goto END;
      }
      ll aizu=1,n=(b-c1)/c2;
      b-=c1+n*c2;
      if(aizu+n<q1){
        puts("NA");
        goto END;
      }

      while(aizu+n>=q1 && aizu<=q2 && n>=0){
        while(b<c1){
          n--;
          b+=c2;
        }
        ++aizu;
        b-=c1;
      }

      --aizu;
      b+=c1;
      n+=b/c2;
      if(aizu<1 || aizu+n<q1){
        puts("NA");
      }else{
        cout<<aizu<<" "<<n<<endl;
      }
    }
END:;
  }
}

C++: #include<iostream>


using namespace std;


typedef struct struct_input
{
	//欲しい肉の量
	int niku;
	//予算
	int yosan;
	//地鶏の値段
	int didori_nedan;
	//普通の
	int normal_tori;
	//地鶏を最大で買える数
	int didori_max;
}S_input;


S_input s_input;




int main(void)
{
	while (true){
		int aizu = 0;
		int normal = 0;
	
		cin >> s_input.niku;
		if (s_input.niku == 0){
			return 0;
		}

		cin >> s_input.yosan >> s_input.didori_nedan >> s_input.normal_tori >> s_input.didori_max;

		for (int i = 0; i < s_input.didori_max; i++){
			if (s_input.didori_nedan > s_input.yosan){
				break;
			}
			s_input.yosan -= s_input.didori_nedan;
			aizu++;
		}

		normal = s_input.yosan / s_input.normal_tori;
		s_input.yosan %= s_input.normal_tori;

		if (aizu + normal >= s_input.niku && aizu >= 1){
			cout << aizu << " " << normal << endl;
			continue;
		}

		while (s_input.niku > aizu + normal){
			if (aizu <= 1){
				break;
			}
			s_input.yosan += s_input.didori_nedan;
			aizu--;

			while (s_input.yosan > s_input.normal_tori){
				s_input.yosan -= s_input.normal_tori;
				normal++;
			}
		}

		if (aizu + normal >= s_input.niku && aizu >= 1){
			cout << aizu << " " << normal << endl;
			continue;
		}
		cout << "NA" << endl;
	}

	return 0;
}

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

int q1,q2,b,c1,c2,ans1,ans2;

bool solve(){
	ans1 = q2;
	ans2 = 0;
	while(ans1*c1 + ans2*c2 <= b)
		ans2++;
	if(ans2)
		ans2--;
	if(ans1 + ans2 >= q1 && ans1*c1 + ans2*c2 <= b && ans1!=0)
		return true;
	while(true){
		ans1--;
		while(true){
			ans2++;
			if(ans1*c1 + ans2*c2 > b){
				ans2--;
				break;
			}
		}
		if((ans1*c1 + ans2*c2 <= b && ans1 + ans2 >= q1) || ans1 == 0)
			break;
	}
	if(!ans1)
		return false;
	else
		return true;
}

int main(){
	while(true){
		cin >> q1;
		if(!q1)
			return 0;
		cin >> b >> c1 >> c2 >> q2;
		if(solve())
			cout << ans1 << ' ' << ans2 << endl;
		else
			cout << "NA" << endl;
	}
}

C++: #include <iostream>
#include<iomanip>
#include<algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;

int lm,bud,an,cn,um;
pair<int,int> dp[1000005];

int main(){
	while(1){
		bool used=false;
		cin>>lm;
		if(lm==0) break;
		cin>>bud>>an>>cn>>um;
		for(int i=um;i>0;i--){
			int tmp=(bud-i*an)/cn;
			if(i+tmp>=lm){
				cout<<i<<' '<<tmp<<endl;
				used=true;
				break;
			}
		}
		if(!used) cout<<"NA"<<endl;
	}
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int q1, b, c1, c2, q2;
        cin >> q1 >> b >> c1 >> c2 >> q2;
        if(q1 == 0)
            return 0;

        if((b - c1) / min(c1, c2) < q1 - 1)
            cout << "NA" << endl;
        else{
            int x = 1;
            int y = q2;
            while(x != y){
                int z = (x + y + 1) / 2;
                if(b - z*c1 >= 0 && (b - z*c1) / c2 >= q1 - z)
                    x = z;
                else
                    y = z-1;
            }
            cout << x << ' ' << ((b - x*c1) / c2) << endl;
        }
    }
}

C++: #include<stdio.h>
int main()
{
	int q1,q2,c1,c2,b,x,y;
	while(scanf("%d%d%d%d%d",&q1,&b,&c1,&c2,&q2)>1)
	{
		x=1;
		while(y=(b-x*c1)/c2, b>=x*c1&&x<q2&&x+y>=q1)
			++x;
		if(b<x*c1 || x+y<q1) --x,y=(b-x*c1)/c2;	if(!x||x+y<q1)puts("NA");
		else printf("%d %d\n",x,y);
	}
	return 0;
}

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

int main(){
	int b,c1,c2,q1,q2,aizu,ord;
	bool flag=false;

	while(cin>>q1,q1){
		cin>>b>>c1>>c2>>q2;
		if(b/c1>q2){
			aizu=q2;
			ord=(b-c1*q2)/c2;
		}else{
			aizu=b/c1;
			ord=(b%c1)/c2;
		}
		//cout<<aizu<<" "<<ord<<endl;
		if(c1>b){cout<<"NA"<<endl;}
		else if((aizu+ord)<q1){
			for(int i=aizu-1;i>0;i--){
				if((c1*i+c2*(q1-i))<b){
					flag=true;
					cout<<i<<" "<<q1-i<<endl;
					break;
				}
			}
			if(!flag) cout<<"NA"<<endl;
		}else{
			cout<<aizu<<" "<<ord<<endl;
		}
	}
	return 0;
}

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;
}