GeeksforGeeksSolution ForSchoolDomain .Below You Can Find The Solution OfBasic ,Easy ,Medium ,Hard.You Can Also Direct Submit Your Solution toGeeksforgeeksSame Problem .You Need to login then you can submit you answers

**Problem :-**Given two positive numbers x and y, check if y is a power of x or not.

**Submit Your Solution :-**

**Click Here**

**Solution :-**

#include <iostream>

#include<math.h>

using namespace std;

int main()

{

int t;

cin>>t;

while(t--)

{

int x,y,z=1,z1=0,i;

cin>>x>>y;

if(x==1 && y==1){

cout<<"1\n";

continue;

}

else if(x==1){

cout<<z1<<endl;

continue;

}

//break;

while(y%x==0)

y/=x;

if(y==1)

cout<<"1\n";

else

cout<<"0\n";

}

return 0;

}

**Output:-**

Sorry to say but this solutions are complicated to understand. And please try to present in more clean way it looks hectic.

ReplyDelete