Run ID:3111

提交时间:2024-04-05 16:31:01

#include<iostream> using namespace std; int n,st[100000001]; int ans=0; void Era(int x){ st[0]=st[1]=1; for(int i=2;i<=x/i;i++){ if(!st[i]){ for(int j=i*i;j<=x;j+=i){ st[j]=1; } } } //for(int i=1;i<=x;i++) // if(!st[i])cout<<i<<" "; } int main(){ int n; cin>>n; Era(n); for(int i=1;i<=n;i++){ if(!st[i]){ int temp=i; while(temp>0){ temp/=10; if(st[temp]==1)break; } if(temp==0)ans++; } } cout<<ans<<endl; return 0; }