题解 | #小红的取模构造#

小红的取模构造

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;
}

注意分类讨论

全部评论

相关推荐

不愿透露姓名的神秘牛友
11-03 14:23
海康威视 嵌入式软件开发 总包29w 其他
点赞 评论 收藏
分享
后端转测开第一人:再怎么劝退也没用的 某些群体总以为在一个幸存者偏差的软件上看见了极少数秋招上岸某个大厂的个例就幻想上了 事实上自己打开ssob沟通1000+连个小厂面试都没
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务