#include <iostream>#include <cstdio>
using namespace std;
int main() {
int n;
while (scanf("%d", &n) != EOF) {
for (intx = 0; x <= 100; x++) {
for (inty = 0; y <= 100-x; y++) {
int z = 100 -x - y;
if (15*x+9*y+z <= 3*n) {
printf("x=%d,y=%d,z=%d\n", x, y, z);
}
}
}
}
return0;
}
#include <cstdio>#include <queue>#include <iostream>
using namespace std;
bool mark[101][101][101]; // 标记数组
struct N { // 状态结构体
int a, b, c;
int t;
};
queue<N> Q; // 队列
// 倾倒函数,由体积为sa的杯子倒往容积为sb的杯子,其中引用参数a和b
// 初始时为原始杯子中可乐的体积,当函数调用完毕时,为各自杯子中的新体积
void AtoB(int &a, int sa, int &b, int sb) {
if (sb - b >= a) { // 若a可以全部倒到b中
b += a;
a = 0;
} else {
a -= sb - b;
b = sb;
}
}
int BFS(ints, int n, intm) {
while (!Q.empty()) {
N now = Q.front(); // 得到队头状态
Q.pop(); // 从队列中弹出队头元素
int a, b, c;
a = now.a;
b = now.b;
c = now.c;
AtoB(a, s, b, n); // a -> b
if (mark[a][b][c] == false) {
mark[a][b][c] = true;
N tmp;
tmp.a = a;
tmp.b = b;
tmp.c = c;
tmp.t = now.t+1;
if (a == s/2 && b == s/2) return tmp.t;
if (b == s/2 && c == s/2) return tmp.t;
if (a == s/2 && c == s/2) return tmp.t;
Q.push(tmp);
}
a = now.a;
b = now.b;
c = now.c;
AtoB(b, n, a, s); // b -> a
if (mark[a][b][c] == false) {
mark[a][b][c] = true;
N tmp;
tmp.a = a;
tmp.b = b;
tmp.c = c;
tmp.t = now.t+1;
if (a == s/2 && b == s/2) return tmp.t;
if (b == s/2 && c == s/2) return tmp.t;
if (a == s/2 && c == s/2) return tmp.t;
Q.push(tmp);
}
a = now.a;
b = now.b;
c = now.c;
AtoB(a, s, c, m); // a -> c
if (mark[a][b][c] == false) {
mark[a][b][c] = true;
N tmp;
tmp.a = a;
tmp.b = b;
tmp.c = c;
tmp.t = now.t+1;
if (a == s/2 && b == s/2) return tmp.t;
if (b == s/2 && c == s/2) return tmp.t;
if (a == s/2 && c == s/2) return tmp.t;
Q.push(tmp);
}
a = now.a;
b = now.b;
c = now.c;
AtoB(c, m, a, s); // c -> a
if (mark[a][b][c] == false) {
mark[a][b][c] = true;
N tmp;
tmp.a = a;
tmp.b = b;
tmp.c = c;
tmp.t = now.t+1;
if (a == s/2 && b == s/2) return tmp.t;
if (b == s/2 && c == s/2) return tmp.t;
if (a == s/2 && c == s/2) return tmp.t;
Q.push(tmp);
}
a = now.a;
b = now.b;
c = now.c;
AtoB(b, n, c, m); // b -> c
if (mark[a][b][c] == false) {
mark[a][b][c] = true;
N tmp;
tmp.a = a;
tmp.b = b;
tmp.c = c;
tmp.t = now.t+1;
if (a == s/2 && b == s/2) return tmp.t;
if (b == s/2 && c == s/2) return tmp.t;
if (a == s/2 && c == s/2) return tmp.t;
Q.push(tmp);
}
a = now.a;
b = now.b;
c = now.c;
AtoB(c, m, b, n); // c -> b
if (mark[a][b][c] == false) {
mark[a][b][c] = true;
N tmp;
tmp.a = a;
tmp.b = b;
tmp.c = c;
tmp.t = now.t+1;
if (a == s/2 && b == s/2) return tmp.t;
if (b == s/2 && c == s/2) return tmp.t;
if (a == s/2 && c == s/2) return tmp.t;
Q.push(tmp);
}
}
return -1;
}
int main() {
ints, n, m;
while (scanf("%d%d%d", &s, &n, &m) == 3) {
if (s == 0) break;
if (s & 1) {
printf("NO\n");
continue;
}
memset(mark, false, sizeof(mark));
while (!Q.empty())
Q.pop();
mark[s][0][0] = true;
N tmp;
tmp.a = s;
tmp.b = 0;
tmp.c = 0; // 初始状态
tmp.t = 0;
Q.push(tmp);
int rec = BFS(s, n, m);
if (rec == -1)
printf("NO\n");
elseprintf("%d\n", rec);
}
return0;
}