您的位置:首页 > 其它

1194:Beat the Spread!

2015-08-28 14:12 253 查看
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1194

方法:无,解方程算是吗?

思路:大水题,但是有一个细节需要关注,那就是比赛的得分要求是非负的整数,所以在解完方程后要关注到数据的筛选问题。

难点:关注细节处理

#include <iostream>
using namespace std;
int main()
{
    int t,sum,sub,n1,n2;
    while(cin>>t)
    {
        while(t--)
        {
            cin>>sum>>sub;
            n1 = (sum+sub)/2;
            n2 = sum - n1;
            if(n1 < 0||n2 < 0||(sum+sub)%2 != 0)
                cout<<"impossible"<<endl;
            else
                cout<<n1<<" "<<n2<<endl;
        }
    }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: