1 #include<iostream> 2 using namespace std; 3 4 int main() 5 { 6 int n, m; 7 while (cin >> n >> m,n!=0,m!=0) 8 { 9 int n_dove, n_rabbit; 10 if (m % 2 == 0&&(m>2*n)&&(4*n>m)) 11 { 12 n_dove = (4 * n - m) / 2; 13 n_rabbit = n-n_dove; 14 cout << n_dove << " " << n_rabbit << endl; 15 } 16 else 17 cout << "Error" << endl; 18 } 19 return 0; 20 }
要考虑结果的正负性(m-2*n>0&&4*n-m>0)及int情况下的整数性(m%2==0)