Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
1.1 kB
2
Indexable
Never
#include<bits/stdc++.h>
using namespace std;
vector<int> c;
void Phantich(int n)
{
    c.clear();
    int i=2;
    while (i*i<=n)
    {
        while (n%i==0)
        {
            n/=i;
            c.push_back(i);
        }
        i++;
    }
    if (n>1) c.push_back(n);
}
bool check(vector<int> c1)
{
    string s="";
    for (int i=0;i<c1.size();i++) s+=to_string(c1[i]);
    for (int i=0;i<s.size()/2;i++)
        if (s[i]!=s[s.size()-1-i]) return 0;
    return 1;
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int a,b;
    cin>>a>>b;
    int ans=0;
    if (a<2) a=2;
    for (int i=a;i<=b;i++)
    {
        Phantich(i); //Phan tich thua so nguyen to

        //----Sinh hoan vi-----
        if (check(c))
        {
            ans++;
            continue;
        }
        while (next_permutation(c.begin(),c.end()))
        {
            if (check(c))
            {
                ans++;
                break;
            }
        }


    }
    cout<<ans;
    return 0;
}