题解 | #小红的取模构造#
小红的取模构造
https://www.nowcoder.com/practice/679758a0bde0479d88463438ccee81c4
# include<bits/stdc++.h> using namespace std; int t,a,b; int main(){ cin>>t; while(t--){ cin>>a>>b; if(a==b && a!=0){ cout<<-1<<" "<<-1<<endl; continue ; } if(a==b && a== 0){ cout<<1<<" "<<1<<endl; continue; } if(a>b){ if(a+b != a) cout<<a<<" "<<a+b<<endl; else cout<<a<<" "<<2*a+b<<endl; continue; } if(a<b){ if(a+b != b) cout<<b+a<<" "<<b<<endl; else cout<<2*b+a<<" "<<b<<endl; continue; } } return 0; }
注意分类讨论