### ABhinav2003's blog

By ABhinav2003, history, 4 years ago,
#include<bits/stdc++.h>
using namespace std;

long long int emerald(long long int sticks ,long long int diamonds)
{

if(sticks <= 0 || diamonds <= 0 ||(sticks == 1 && diamonds == 1) )
return 0;

else
return max(1+emerald(sticks - 1 , diamonds-2), 1+emerald(sticks-2,diamonds-1));
}

int main()
{

int t;
cin>>t;
while(t--)
{
long long int sticks , diamonds;
cin>>sticks>>diamonds;

cout<<emerald(sticks,diamonds)<<"\n";

}
}


-----------------------------------------------------------------------

## HERE IS THE QUESTION — (https://codeforces.com/contest/1366/problem/A) |

• -24

By ABhinav2003, history, 4 years ago,
#include<bits/stdc++.h>
using namespace std;
int in=0 , ex;
int sub(int a[] , int len)
{
//	if(len<1)
//		return 0;
if(len <= 0  )
return 0;

ex = sub(a,len-1);
cout<<"EX "<<ex<<"\n";

if(a[len-1] >a[len-2])
{
int t = a[len-1]>a[len-2];cout<<"T "<<t<<"\n";
in = 1+sub(a,len-1);
}
cout<<"IN "<<in<<"\n";

int max1 = max(in,ex);
cout<<"MAX "<<max1<<"\n";

return max1;
}

int main()
{
int len;
cin>>len;
int a[len];
for(int i = 0;i<=len-1;i++)
{
cin>>a[i];
}
int m = sub(a , len);
cout<<m;
}
[**HERE IS THE PROBLEM**](https://codeforces.com/problemset/problem/702/A)

• 0

By ABhinav2003, history, 4 years ago,
#include<bits/stdc++.h>
using namespace std;

int sub(int a[] , int len)
{
if(len == 0)
return 0;

if(a[len-1]<a[len-2])
return 0;

return max(1+sub(a , len-1) , sub(a , len-2));
}

int main()
{
int len;
cin>>len;
int a[len];
for(int i = 0;i<=len-1;i++)
{
cin>>a[i];
}
int m = sub(a , len);
cout<<m;
}[LINK TO THE PROBLEM](https://codeforces.com/problemset/problem/702/A)

• -1

By ABhinav2003, history, 4 years ago,

Hello folks, I have been coding since 3 months on codeforces but i wanted to know some good books to start with in Algorithms as i look forward to compete in IOI olympiad plz provide some guidance .

• -45

By ABhinav2003, history, 4 years ago,

//THIS IS MY SOLUTION

# include<bits/stdc++.h>

using namespace std;

bool prime(long long int a) { bool c= true; for(int i = 2;i<=sqrt(a);i++) { if(a%i == 0) { c = false; break; } } if(c == true ) return true; else return false;

}

bool T_PRIME(long long int a) { float test = sqrt(a) ; int test1 = floor(sqrt(a));

if(test - test1 == 0)
{
if(prime(sqrt(a)) == true)
return true;
else
return false;
}
else
return false;


}

int main() { int t; cin>>t; vector a; for(int i = 0;i<t;i++) { int k; cin>>k; a.push_back(k);

}

for(auto i : a)
{
if(T_PRIME(i) == true)
cout<<"YES"<<"\n";
else
cout<<"NO"<<"\n";
}


}

• -28