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(;;) {
      
      if(AizuCh + NCh >= Q1) {
        cout << AizuCh << ' ' << NCh << endl; break;
      }
      
      else if(B - (NCh+1)*C2 - AizuCh*C1 >= 0) {
        while(B - (NCh+1)*C2 - AizuCh*C1 >= 0) NCh ++;
      }
      else if(B - (NCh+1)*C2 - (AizuCh-1)*C1 >= 0) {
        NCh ++, AizuCh --;
      }
      
      if(AizuCh == 0) { failed(); break; }
    }
    
  }
  
  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;
	while(cin>>q1>>b>>c1>>c2>>q2,q1){
		int a=b/c1,d=0,sum=a*c1;
		for(;a>0&&(a>q2)||(a+d<q1);){
			a--; sum-=c1;
			while(sum+c2<b)d++,sum+=c2;
		}
		if(0<a&&a+d>=q1)cout<<a<<" "<<d<<endl;
		else cout<<"NA"<<endl;
	}
	return 0;
}

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);
    if(AizuCh == 0) {
      failed(); continue;
    }
    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 <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;

    int cnt2 = b / c2;
    if(cnt2 < 0){
      cnt2 = 0;
    }
    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){
      puts("NA");
    }else{
      printf("%d %d\n" ,cnt1 ,cnt2);
    }
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int a,b,c,d,e;
  while(cin >>a,a){
    cin >>b>>c>>d>>e;
    int x;
    for(int i=b/c; i>=0; i--){
      if(i == 0){cout <<"NA"<<endl;break;}
      if(e>=i){
	x = (b-i*c)/d;
	if(x+i >= a){cout <<i<<" "<<x<<endl;break;}
      }
    }
  }
  return 0;
}

C++: // 2011/08/22 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int q1;
		cin >> q1;
		if(q1==0)
			break;

		int b, c1, c2, q2;
		cin >> b >> c1 >> c2 >> q2;

		int A = (b-c2*q1)/(c1-c2);
		if(A<=0){
			cout << "NA" << endl;
			continue;
		}
		if(A>q2)
			A = q2;

		int B = (b-c1*A)/c2;
		if(B<0){
			A = b/c1;
			B = (b-c1*A)/c2;
		}

		cout << A << ' ' << B << endl;
	}

	return 0;
}

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

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

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

		if(c1 + c2 * (q1 - 1) > b) cout << "NA" << endl;
		else
		{
			int cnt = 1,cnt_2 = q1 - 1,res = c1 + c2 * (q1 - 1);
			bool flag = false;

			while(res < b)
			{
				if(cnt < 0 || cnt_2 < 0) 
				{
					flag = true;
					break;
				}

				if(cnt <= q2)
				{
					res += c1 - c2;
					cnt++;
					cnt_2--;
				}
				else break;
			}

			cnt--;
			cnt_2++;
			res -= c1 - c2;
			
			if(cnt == q2)
			{
				cnt_2 += (b-res)/c2;
			}

			if(flag)
			{
				cnt += (b-res)/c1;
			}

			cout << cnt << " " << cnt_2 << endl;
		}

	}
	return 0;
}

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

#define f first
#define s second
#define mp make_pair

#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()

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int main(){
  int b,c1,c2,q1,q2;
  while(cin>>q1, q1){
    cin>>b>>c1>>c2>>q2;
    /*
      b = c1 * x + c2 * (q1 - x);
      b = (c1 - c2) * x + c2 * q1;
      x = (b - c2 * q1) / (c1 - c2);
    */
    int aizu;
    int norm;

    if(c1 <= c2){
      aizu = min(q2, b / c1);
    }else{
      if(b >= q1 * c1){
        aizu = min(q2, b / c1);
      }else{
        aizu = min(q2, (b - c2 * q1) / (c1 - c2));
      }
    }
    int money = b - c1 * aizu;
    if(aizu == 0) goto err;
    //printf("aizu = %d\n", aizu);
    //printf("money = %d\n",money);
    if(money < 0) goto err;
    norm = money / c2;
    if(norm + aizu < q1) goto err;
    cout << aizu << " " << norm << endl;
    continue;
  err:
    cout << "NA" << endl;
  }
  return 0;
}