题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1364
//C++代码
#include<iostream>
using namespace std;
int main(){
int n,a,b;
cin>>n;
while(n--){
cin>>a>>b;
if(a<b || (a+b)&1) cout<<"impossible"<<endl;
else cout<<(a+b)/2<<" "<<(a-b)/2<<endl;
}
return 0;
}
本文提供了ZJU OJ 1364题目的C++解决方案,通过判断输入的两个整数是否能构成有效的一对,并输出对应的解。该算法考虑了奇偶性和数值关系。
271

被折叠的 条评论
为什么被折叠?



