#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
using namespace std;
int s=0,a,b,c,z[4000005]={1,1,0,0};
int h(int s)
{
while(s>0)
{
if(s%10==c)
return 1;
s/=10;
}
return 0;
}
int main()
{
freopen("qprime.in","r",stdin);
freopen("qprime.out","w",stdout);
string word;
int i=2,j=1;
cin>>a>>b>>c;
for(i=2;i<=ceil(sqrt(b));++i)
{
if(z[i])continue;
for(j=i*i;j<=b;j+=i)
z[j]=1;
}
for(i=a;i<=b;++i)
if(!z[i])
if(h(i))++s;
cout<<s;
fclose(stdin);
fclose(stdout);
return 0;
}
177. [USACO Jan07] 有限制的素数
最新推荐文章于 2022-12-28 19:38:37 发布