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 <algorithm>
#include <cmath>
#include <cassert>

using namespace std;

void failed() {
  cout << "NA" << endl;
}

int main() {
  
  int Q1, B, C1, C2, Q2;
  
  while(cin >> Q1 >> B >> C1 >> C2 >> Q2) {
    if(Q1 == 0) break;
    
    if(B/C1 == 0) {
      failed(); continue;
    }
    
    int AizuCh = min(B/C1, Q2);
    int NCh = 0;
    for(;;) {
      
      NCh = (B - AizuCh*C1)/C2;
      
      /*
      if(B - (NCh+1)*C2 - AizuCh*C1 >= 0) {
        NCh = (B - AizuCh*C1)/C2;
      }
      */
      if(AizuCh + NCh >= Q1) {
        cout << AizuCh << ' ' << NCh << endl; break;
      }
      /*
      else if(B - (NCh+1)*C2 - (AizuCh-1)*C1 >= 0) {
        NCh ++, AizuCh --;
      }
      */
      else AizuCh --;
      
      if(AizuCh <= 0) { failed(); break; }
    }
    
  }
  
  return 0;
}

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

int main(void){
	int i,b,c1,c2,q1,q2,sum,ansA,ansB;
	bool flg;

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

		flg = false;
		for(ansA=q2;ansA>=1;ansA--){
			ansB = (b-c1*ansA);
			if(ansB >= 0) ansB /= c2;
			else ansB = -1;

			if(ansB >= 0 && ansA + ansB >= q1){
				flg = true;
				break;
			}
		}

		if(flg) cout<<ansA<<" "<<ansB<<endl;
		else cout<<"NA\n";
	}

	return 0;
}

C++: #include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
int cnt[7];
int main(){
    long les,m,a,c,w;
    while(cin>>les,les){
        cin>>m>>a>>c>>w;
        int ch=0;
        long cc=0;
        int i=0;
        long k=m/a;
        if(m/c<les||k==0){
            cout<<"NA"<<endl;
            continue;
        }
        if(k>w)k=w;
        for(i=k;i>0;i--){
            cc=(m-i*a)/c;
            if(cc+i>=les) {
                ch=1;
                break;
            }
        }
        if(ch) cout<<i<<" "<<cc<<endl;
        else cout<<"NA"<<endl;
    }
    return 0;
}

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 if(q1 * c1 > b){
			ans1 = min((b - q1 * c2) / (c1 - c2), q2);
			ans2 = (b - c1 * ans1) / c2;
		}else{
			ans1 = min(b / c1, q2);
			ans2 = (b - c1 * ans1) / c2;
		}
		
		
		if(ans1 < 1 || ans2 < 0){
			cout << "NA" << endl;
		}else{
			cout << ans1 << " " << ans2 << endl;
		}
		
		//cout << ans1 << " " << ans2 << endl;
	}
	
	return 0;
}

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;
		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){
							ans = P(i, co);
						}
					}
				}
				else{
					if (i*c1 <= b){
						ans = P(i, 0);
					}
				}
			}
			if (ans.first >= 0 && ans.second >= 0)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 <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 <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int INF = 1e9 + 7;

int q1, b, q2;
double c1, c2;

int check(int x){
  if(x < 0 || x > q2) return -1;
  double p = (x / 100) * c1;
  if(p > b) return -1;
  int y = (b - p) / c2;
  y *= 100;
  if(x + y < q1) return -1;
  return y;
}
 
int main() {
  while(cin >>q1 && q1){
    cin >>b >>c1 >>c2 >>q2;
    q1 *= 100; q2 *= 100;
    int x = -1, y = -1, tmp;
    for(int i = 10000000; i >= 100; i -= 100) if((tmp = check(i)) != -1) { x = i; y = tmp; break; }
    if(x == -1) cout <<"NA" <<endl;
    else cout <<x / 100 <<" " <<y / 100 <<endl;
  }
  return 0;
}