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>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <cassert>
using namespace std;

//common
typedef int  i32;
typedef long long i64,ll;
#define BR "\n"

#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;

//config
#define MODE_DEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef MODE_DEBUG
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl

#define  DUMP(x)  cerr << #x << " = " << (x) <<endl
#define DEBUG(x) DUMP(x) << " (L" << __LINE__ << ")" << " " << __FILE__<<endl
#define CHECK(exp,act)  if(exp!=act){DUMP(exp);DEBUG(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#else
#define DUMP(x)
#define DEBUG(x)
#define CHECK(exp,act)
#define STOP(e)
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}
template<class T> inline string toString(const vector<vector<T>>& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

const int INF=1<<28;
int main(){
	while(true){
		loop:
		int q1;cin >> q1;
		if(q1==0)break;
		int b,c1,c2,q2;cin >> b >> c1 >> c2 >> q2;

		for(int res1=q2;res1>=1;res1--){
			if(b-res1*c1<0)continue;
			int res2=(b-res1*c1)/c2;
			if(res1+res2>=q1){
				cout << res1 << " "<< res2 <<endl;
				goto loop;
			}
		}
		cout <<"NA"<<endl;
	}

	return 0;
}

C++: #include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int q1,b,c1,c2,q2,a,d;
	while(cin>>q1>>b>>c1>>c2>>q2,q1)if(c1+c2>b||(b-c1)/c2+1<q1)cout<<"NA"<<endl;
	else{
		int a=b/c1>q2?q2:b/c1,d=(b-a*c1)/c2;
		for(;a+d<q1;){
			a--;
			d=(b-a*c1)/c2;
		}
		cout<<a<<" "<<d<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll q,b,c1,c2,q2;
  while(cin >> q && q){
    cin >> b >> c1 >> c2 >> q2;
    ll A=0,B=0,C = b;
    A = min(q2,b / c1);
    b -= A * c1;
    B = b / c2;
    b = C;
    while(A+B<q){
      --A;
      b -= A * c1;
      B = b / c2;
      b = C;
      if(A==0) break;
    }
    if(A == 0){
      cout << "NA"<<endl;
    }
    else{
      cout << A << " " << B <<endl;
    }
  }
  return 0;
}

C++: #include <vector>
#include <algorithm>
#include <functional>
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main()
{
    int b, c1, c2, q1, q2;
    while(cin >> q1 && q1) {
        cin >> b >> c1 >> c2 >> q2;
        int a, a1, a2, d;
        a = b / c1;
        bool ok = false;
        for(int i = 0; !ok && i < a; i++) {
            a1 = a - i;
            if(a1 > q2) a1 = q2;
            a2 = (b - a1 * c1) / c2;
            if(a1 + a2 >= q1) ok = true;
        }
        
        if(ok) {
            cout << a1 << " " << a2 << endl;
        } else {
            cout << "NA" << endl;
        }
        
    }
    return 0;
}

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

int main()
{
	int q1, b, c1, c2, q2;

	while( cin >> q1 && q1 ){
		cin >> b >> c1 >> c2 >> q2;
		int a1, a2;
		a1 = b / c1;
		if( a1 > q2 ){
			a1 = q2;
		}
		a2 = ( b - c1 * a1 ) / c2;
		if( a1 + a2 < q1 ){
			int s = q1 - ( a1 + a2 );
			int cc = c1 - c2;
			if( cc > 0 ){
				double cb = static_cast< double >( cc ) / c2;	// can buy:１個交換するとc2がcb個買えるようになる
				double swtmp = s / cb;
				int sw = static_cast<int>( swtmp );
				int swn = static_cast<int>( sw * cb );
				a1 -= ( swn - 1 );
				do{
					--a1;
					a2 = ( b - c1 * a1 ) / c2;
				}while( a1 > 0 && a1 + a2 < q1 );
				if( a1 > 0 ){
					a2 = ( b - c1 * a1 ) / c2;
				}else{
					a1 = a2 = -1;
				}
			}else{
				a1 = a2 = -1;
			}
		}
		if( a1 == 0 || ( a1 == -1 && a2 == -1 ) ){
			cout << "NA" << endl;
		}else{
			cout << a1 << " " << a2 << endl;
		}
	}

	return 0;
}