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>
using namespace std;

int main(){
    int q1, b, c1, c2, q2;
    while(1){
        cin >> q1;
        if(q1 == 0) break;
        cin >> b >> c1 >> c2 >> q2;

        int aizu = min(q2, b/c1);
        b -= aizu * c1;
        int normal = b/c2;
        b -= normal * c2;

        if(aizu + normal < q1 && c1 > c2){
            while(aizu + normal < q1 && aizu > 0){
                aizu--;
                b += c1;
                normal += b/c2;
                b %= c2;
            }
        }

        if(aizu > 0 && aizu + normal >= q1) cout << aizu << " " << normal << endl;
        else                    cout << "NA" << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

signed main(){
    int q1, b, c1, c2, q2;
    while(cin >> q1, q1){
        cin >> b >> c1 >> c2 >> q2;
        int x, y;
        x = min(b / c1, q2);
        b -= c1*x;
        y = b / c2;
        while(x){
            if(x + y >= q1) break;
            x--;
            b += c1;
            y = b / c2;
        }
        if(x == 0) cout << "NA" << endl;
        else cout << x << ' ' << y << endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
int q,b,c1,c2,limit;

int check(int M){
  int B=b,cnt=M;
  B-=c1*M;
  if(B<0) return 0;
  cnt+=(B/c2);
  return (cnt>=q);
}

int main(){
  while(cin>>q,q){;
    cin>>b>>c1>>c2>>limit;

    int L=0,M,R=limit+1;
    while(L<R) {
      M=(R+L)/2;
      if(!check(M)) R=M;
      else L=M+1;
    }
    if(L<=1) cout <<"NA"<<endl;
    else cout <<(L-1)<<" "<<((b-(L-1)*c1)/c2)<<endl;
    
  }
  return 0;
}

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

int a,b,c,d,e;

int main(){
	while(cin>>a){
		if(a==0){break;}
		cin>>b>>c>>d>>e;
		if(c*e+d*(a-e)<=b){
			for(int i=0;i<100000;i++){
				if(c*e+d*(a-e)>b){
					cout<<e<<' '<<a-e-1<<endl;
					goto E;
				}
				a++;
			}
		}
		else{
			for(int i=0;i<=a;i++){
				if(c*e+d*(a-e)<=b){
					cout<<e<<' '<<a-e<<endl;
					goto E;
				}
				e--;
			}
		}
		cout<<"NA"<<endl;
		E:;
	}
}

C++: #include<iostream>
using namespace std;
int main(){
  int count=0,count2=0,b,c1,d=0,i,j,q1,c2,q2,y=0;
  while(1){
    j=0;
    y=0;
    count=0;
    count2=0;
    cin >> q1;
    if(q1==0){
      break;
    }
    cin >> b >> c1 >> c2 >> q2;
    if(b<c1){
      cout << "NA" <<endl;
      continue;
    }
    while(b>c1){
      b=b-c1;
      count++;
      if(count >= q2){
	break;
      }
    }
    if(b<c2 && count<q1){
      cout << "NA" <<endl;
      continue;
    }
    if(b>=c2){
      while(b>c2){
	b=b-c2;
	count2++;
      }
    }
    if(count+count2<q1){
      while(count+count2<q1){
	d=0;
	if(count==0){
	  cout << "NA" << endl;
	  j=1;
	  break;
	}
	count--;
	b=b+c1;
	while(c1>c2*d){
	  count2++;
	  b=b-c2;
	  d++;
	  if(count+count2>=q1){
	    y=1;
	    break;
	  }
	}
	if(y==1){
	  break;
	}
      }
    }
    if(j!=1){
      cout << count << " " << count2 <<endl;
    }
  }
}

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


int main(){
	int q1,b,c1,c2,q2;
	while(cin>>q1,q1){
		cin>>b>>c1>>c2>>q2;
		int NA=1;
		for(int i=q2;i>0;i--){
			int j=c1*i;
			int k=(b-j)/c2;
			if(b>=j&&i+k>=q1){
				cout<<i<<" "<<k<<endl;
				NA=0;
				break;
			}
		}
		
		
		if(NA)cout<<"NA\n";
	}
	
	
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main()
{
  int q1, b, c1, c2, q2;
  while(cin >> q1, q1){
    cin >> b >> c1 >> c2 >> q2;
    int aizu = min(q2, b/c1);
    int money = b - aizu*c1;
    int tori = max(money/c2, 0);
    money -= tori*c2;
    int up = 0;
    while(aizu > 0 && (money < 0 || aizu + tori < q1)){
      //cout << aizu << " " << tori << " " << money << endl;
      aizu--;
      money += c1;
      up = max(money/c2, 0);
      money -= up*c2;
      tori += up;
    }
    if(aizu != 0 && aizu + tori >= q1) cout << aizu << " " << tori << endl;
    else cout << "NA" << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int q1, b, c1, c2, q2;
long lev;


bool C(long x){	
	lev = (b-c1*x)/c2;//ツ閉津環鶏ツ禿キツ。
	if(b-c1*x<0)return false;
	if(q2<x)    return false;
	if(lev<0)   return false;
	return x+lev>=q1;
}


void solve(){
	long l=0, u=10000000;


	for(int i=0; i<100; i++){
		long m=(l+u)/2;
		C(m)?l=m
			:u=m;
	}
	if(u-1+lev>=q1&&u-1>0){
		if(lev<0)lev=0;
		cout<<u-1<<' '<<lev<<"\n";
	}else
		cout<<"NA\n";
 }  
  
int main(){ 	
	while(cin>>q1){
		if(!q1)break;
		cin>>b>>c1>>c2>>q2;
		solve();
	}
    return 0;  
}

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)
	{
		if(c1>c2)
		{
			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;
		}
		else y=0,x=b/c1;

		if(!x||x+y<q1)puts("NA");
		else printf("%d %d\n",x,y);
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<functional>
#include<list>
#include<unordered_map>
#include<map>
using namespace std;

int main() {
	int a, b, c, d, e;
	while (cin >> a, a) {
		cin >> b >> c >> d >> e;
		if (b / c < a&&b / d < a) { puts("NA"); continue; }
		int s = 1, g = e+1;
		while (g - s > 1) {//????´\??°?¶????K??°????????\???????????????
			int k = (s + g) / 2;
			int f = c*k;
			if (f > b) { g = k; continue; }
			f = b-f;
			f = f / d;
			if (k + f >= a) {
				s = k;
			}
			else {
				g = k;
			}
		}
		cout << s<<" "<<(b - (s*c))/d << endl;
	}
}

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

using namespace std;

int q1, b, c1, c2, q2;

bool C(int x)
{
	if (x > q2) return false;

	if (b - (c1 * x) < 0) return false;
	//if (c2 * (q1 - x) < 0) return false;

	if (b - (c1 * x) >= c2 * (q1 - x)) return true;
	else return false;
}

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

		if (c1 > b)
		{
			cout << "NA" << endl;
			continue;
		}

		int lb = 1, ub = 1000000;
		bool flag = false;

		for (int i = 0; i < 100; i++)
		{
			int mid = (lb + ub) / 2;
			if (C(mid))
			{
				lb = mid;
				flag = true;
			}
			else
			{
				ub = mid;
			}
		}

		if (flag)
		{
			int x = lb;
			int y = (b - (c1 * x)) / c2;
			cout << x << " " << y << endl;
		}
		else
		{
			cout << "NA" << endl;
		}
	}
}