GeeksforGeeks Solution For School Domain .Below You Can Find The Solution Of Basic ,Easy ,Medium ,Hard .You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers
Problem :- Shaggy has a frog Akki. Akki is very hungry and Shaggy decides to feed it by playing a little game. Akki is a special frog which can jump as far as it wants but has a special pattern: He starts at the point 0.
In his first turn, he can make a jump of 1 unit. Now for all consequent turns, if the frog is currently at a distance x (from the start), his jump will take him x units forward. Given a leaf at a distance N , you have to find if the frog can reach that leaf or not.
Submit Your Solution :- Click Here
Solution :-
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int i,n,flag=0,x;
cin>>x;
for(i=0;i<17;i++)
{
n=pow(2,i);
if(n==x)
{
flag=1;
break;
}
}
if(flag==1)
cout<<"True\n";
else
cout<<"False\n";
}
return 0;
}
Output:-
0 Comments: