প্রবলেমটি পড়ুন এবং বুঝুন
#include<iostream>
#include<cmath>
using namespace std;
void inquary(unsigned long long int s,unsigned long long int d)
{
unsigned long long int x1,y1,x2,y2;
x1=(s+d)/2;
y1=(s-x1);
if(x1+y1==s && x1-y1==d)
cout<<x1<<" "<<y1<<endl;
else
{
y2=(s+d)/2;
x2=(s-y2);
if(x2+y2==s && y2-x2==d)
cout<<y2<<" "<<x2<<endl;
else
cout<<"impossible\n";
}
}
int main()
{
unsigned long long int test,s,d;
cin>>test;
while(test--)
{
cin>>s>>d;
if(s<d)
cout<<"impossible\n";
else
inquary(s,d);
}
return 0;
}
#include<iostream>
#include<cmath>
using namespace std;
void inquary(unsigned long long int s,unsigned long long int d)
{
unsigned long long int x1,y1,x2,y2;
x1=(s+d)/2;
y1=(s-x1);
if(x1+y1==s && x1-y1==d)
cout<<x1<<" "<<y1<<endl;
else
{
y2=(s+d)/2;
x2=(s-y2);
if(x2+y2==s && y2-x2==d)
cout<<y2<<" "<<x2<<endl;
else
cout<<"impossible\n";
}
}
int main()
{
unsigned long long int test,s,d;
cin>>test;
while(test--)
{
cin>>s>>d;
if(s<d)
cout<<"impossible\n";
else
inquary(s,d);
}
return 0;
}
No comments:
Post a Comment