本题是比较简单的,有几个坑要注意一下:
1、n==0&&m!=0 时输出 "Impossible" ;
2、n==0&&m==0 时输出 ”0 0“;
2、n>m 时最小值为 n,n<m 时最小值为 m;
3、m==0 时最大值,最小值都为 n;
1 #include <iostream> 2 #include <cstring> 3 using namespace std; 4 5 int main (){ 6 int n,m; 7 while (cin>>n>>m){ 8 if (n==0){ 9 if (m==0) 10 cout<<"0 0"<<endl; 11 else 12 cout<<"Impossible"<<endl; 13 continue ; 14 } 15 else if (m==0) 16 cout<<n<<" "<<n<<endl; 17 else 18 cout<<max (n,m)<<" "<<n+m-1<<endl; 19 } 20 return 0; 21 }