#define aavade(a,n) for(int i=0;i<n;i++) cin>>a[i]
#define f(i,x,n) for(int i=x;i<n;i++)
#define bf(i,n,x) for(int i=n-1;i>=x;i--)
#define ll long long int
#define Nottle std::ios::sync_with_stdio(false);
#define Max 1000000000+7
#define ull unsigned long long int
#include<bits/stdc++.h>
using namespace std;
int pal[2000001];
int prime[2000001];
vector <int> factors(int x)
{
vector <int> result;
int i = 1;
while(i*i <= x) {
if(x % i == 0) {
result.push_back(i);
if(x/i != i) {
result.push_back(x/i);
}
}
i++;
}
sort(result.begin(),result.end());
return result;
}
ll fact(ll n)
{
if(n==1 ||n==0)
return 1;
else
return n*fact(n-1);
}
bool isPrime (int number) {
if (number < 2) return false;
if (number == 2) return true;
if (number % 2 == 0) return false;
for (int i=3; (i*i) <= number; i+=2) {
if (number % i == 0 ) return false;
}
return true;
}
bool isPal(int num)
{
string s=to_string(num);
string s1=s;
reverse(s.begin(),s.end());
if(s1==s) return true;
else return false;
}
string getbinary(int x)
{
string s;
bf(i,10,0)
{
s+=to_string((x>>i)&1);
}
return s;
}
int rev (int x){
int res = 0;
while (x){ res = 10*res+x%10;
x/=10;
}
return res;
}
int main()
{
Nottle
prime[2]=1;
f(i,3,1534678)
{
if(isPrime(i))
prime[i]=prime[i-1]+1;
else prime[i]=prime[i-1];
}
pal[1]=1;
f(i,2,1534567)
{
if(rev(i)==i)
pal[i]=pal[i-1]+1;
else pal[i]=pal[i-1];
}
int t;
t=1;
while(t--)
{
int p,q;
cin>>p>>q;
int fl=0;
int i;
// cout<<prime[100000];
for(i=1;i<=1534567;++i)
{
if(q*prime[i]<=p*pal[i])
{
fl=i;
// cout<<i<<" ";
}
}
// cout<<pal[40]<<" "<<prime[40];
if(fl) cout<<fl;
else cout<<"Palindromic tree is better than splay tree";
//cout<<'\n';
}
return 0;
}
1594B - Special Numbers | 1614A - Divan and a Store |
2085. Count Common Words With One Occurrence | 2089. Find Target Indices After Sorting Array |
2090. K Radius Subarray Averages | 2091. Removing Minimum and Maximum From Array |
6. Zigzag Conversion | 1612B - Special Permutation |
1481. Least Number of Unique Integers after K Removals | 1035. Uncrossed Lines |
328. Odd Even Linked List | 1219. Path with Maximum Gold |
1268. Search Suggestions System | 841. Keys and Rooms |
152. Maximum Product Subarray | 337. House Robber III |
869. Reordered Power of 2 | 1593C - Save More Mice |
1217. Minimum Cost to Move Chips to The Same Position | 347. Top K Frequent Elements |
1503. Last Moment Before All Ants Fall Out of a Plank | 430. Flatten a Multilevel Doubly Linked List |
1290. Convert Binary Number in a Linked List to Integer | 1525. Number of Good Ways to Split a String |
72. Edit Distance | 563. Binary Tree Tilt |
1306. Jump Game III | 236. Lowest Common Ancestor of a Binary Tree |
790. Domino and Tromino Tiling | 878. Nth Magical Number |