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 <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

#define INF (1 << 21)

using namespace std;

int N;

int check[100000];

queue<string> que, que_next;

int index(string str){
	
	int ref = 0;
	
	for(int i = 0; i < N; i++){
		ref *= 3;
		ref += str[i] - '0';
	}
	
	return ref;
}

int main(){
	
	while(true){
		
		int b, c1, c2, q1, q2;
		
		cin >> q1;
		
		if(q1 == 0){
			break;
		}
		
		cin >> b >> c1 >> c2 >> q2;
		
		int ans1, ans2;
		
		if(c1 <= c2){
			ans1 = min(b / c1, q2);
			ans2 = (b - c1 * ans1) / c2;
		}else{
			ans1 = min((b - q1 * c2) / (c1 - c2), q2);
			ans2 = (b - c1 * ans1) / c2;
		}
		
		if(ans1 <= 1 || ans2 < 0){
			cout << "NA" << endl;
		}else{
			cout << ans1 << " " << ans2 << endl;
		}
		
	}
	
	return 0;
}

C++: #include <cstdio>

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

  while(scanf("%d" ,&q1) ,q1){
    scanf("%d %d %d %d" ,&b ,&c1 ,&c2 ,&q2);

    int cnt1 = b / c1;
    if(cnt1 > q2){
      cnt1 = q2;
    }

    b -= cnt1 * c1;

    if(0 <= b && q1 <= cnt1){
      printf("%d %d\n" ,cnt1 ,0);
      continue;
    }

    int cnt2 = b / c2;
    b -= cnt2 * c2;

    while(true){
      if(cnt1 + cnt2 >= q1 || cnt1 == 0){    
	break;	
      } 

      cnt1--;
      b += c1;

      b += cnt2 * c2;
      cnt2 = b / c2;
      b -= cnt2 * c2;
    }

    if(cnt1 > 0){
      printf("%d %d\n" ,cnt1 ,cnt2);
    }else{
      puts("NA");
    }
  }

  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
  int want, money, c1, c2, meat;
  
  while(cin >> want){
    if(want == 0) break;
    cin >> money >> c1 >> c2 >> meat;
    
    int ans1 = money / c1;
    if(ans1 > meat) ans1 = meat;
    
    int budget = ans1 * c1;
    int ans2 = 0;
    int sale = money - budget;
    int buy_normal = sale / c2;
    ans2 += buy_normal;
    sale -= buy_normal * c2;
    while(1){
      if(ans1 + ans2 >= want) break;
      if(ans1 == 0) break;
      ans1--, budget -= c1; // テ、ツクツ?」ツ?、テ・ツ」ツイテ」ツつ?
      sale += c1; // テ・ツ」ツイテ」ツ?」テ」ツ?ヲティツイツーテ」ツ?」テ」ツ?淌」ツ?甘ゥツ??
      buy_normal = sale / c2;
      ans2 += buy_normal; //テ・ツ慊ーテゥツカツ湘」ツつ津・ツ」ツイテ」ツ?」テ」ツ?ヲテ」ツ?ァテ」ツ?催」ツ?淌」ツ?甘ゥツ?妥」ツ?ァテ」ツ?ァテ」ツ?催」ツつ凝」ツ??」ツ?妥ゥツカツ湘ィツつ嘉」ツつ津ィツイツキテ」ツ??テ・ツ?凝ヲツ閉ーテッツシツ?     
      sale -= buy_normal * c2;     
      budget += ans2 * c2;
    }
    if(ans1 == 0) cout << "NA" << endl;    
    else cout << ans1 << ' ' << ans2 << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    ll q1, b, c1, c2, q2;
    while(cin >> q1, q1){
        cin >> b >> c1 >> c2 >> q2;
        [&](){
            for (ll i = q2; i >= 1; --i) {
                if(b-c1*i < 0) continue;
                ll j = (b-c1*i)/c2;
                if(q1 <= i+j){
                    cout << i << " " << j << "\n";
                    return;
                }
            }
            puts("NA");
        }();
    }
    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 aizu = min(b / c1, q2);
	   if (aizu == 0) {
		   cout << "NA" << endl;
		   continue;
	   }
	   int money = b - aizu * c1;
	   int ordinal = money / c2;

	   bool possible = true;
	   while (aizu + ordinal < q1) {
		   aizu--;
		   if (aizu == 0) {
			   cout << "NA" << endl;
			   possible = false;
			   break;
		   }
		   money = b - aizu * c1;
		   ordinal = money / c2;
		   money = b - aizu * c1 - ordinal * c2;
	   }
	   if (possible) cout << aizu << ' ' << ordinal << endl;
	}
	return 0;
}

C++: #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 <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
int q1,b,c1,c2,q2;
bool check(int x){
	int bb=b;
	bb-=c1*x;
	if(bb<0) return false;
	int xx=bb/c2;
	if(xx+x>=q1){
		return true;
	}
	return false;
}

int bs(int l,int r){
	if(l==r) return l;
	int mid=(l+r+1)/2;
	if(!check(mid)){
		return bs(l,mid-1);
	}
	return bs(mid,r);
}

void mainmain(){
	while(cin>>q1,q1){
		cin>>b>>c1>>c2>>q2;
		int t=bs(1,q2);
		int tt=(b-c1*t)/c2;
		if(t*c1+tt*c2<=b&&t+tt>=q1) cout<<t<<" "<<tt<<endl;
		else cout<<"NA\n";
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

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

int main()
{
	int q1,money,c1,c2,q2;
	while(cin >> q1){
		if(!q1)
			break;
			cin >> money >> c1 >> c2 >> q2;
			int zidori = min(money/c1,q2);
			int hutuu = 0;
			int kakaku = zidori*c1 + hutuu*c2;
			while(zidori+hutuu < q1){
				while(kakaku < money){
					if(kakaku+c2 < money){
						kakaku += c2;
						hutuu++;
					}
					else
						break;
				}
				if(zidori+hutuu >= q1)
					break;
				zidori--;
				kakaku -= c1;
			}
			if(zidori <= 0 || zidori + hutuu < q1)
				cout << "NA" << endl;
			else
				cout << zidori << " " << hutuu << endl;
	}
	return 0;
}