11565:Simple Equations

Problem Link

#Solution

#include<stdio.h>
#include<stdbool.h>
bool eqn(int a,int b,int c)
{
int i,j,k;
for(i=-100;i<=100;i++)
for(j=-100;j<=100;j++)
for(k=-100;k<=100;k++)
{
if(i!=j&&j!=k&&i!=k&&(i+j+k==a)&&(i*j*k==b)&&(i*i+j*j+k*k==c))
{printf(“%d %d %d\n”,i,j,k);
return true;}
} return false;
}

int main()
{
int a,b,c,t,flag=1;
scanf(“%d”,&t);
while(t–)
{scanf(“%d %d %d”,&a,&b,&c);
if(!eqn(a,b,c))
printf(“No solution.\n”);}
return 0;
}

 

Advertisements

About waprogramming

I am in CSE,from CUET
This entry was posted in Uncategorized, uva and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s