#include #define pb push_back #define NMAX 2005 #define ll long long using namespace std; int cf[]={2,3,5,7},nr,a,b; int numere[10]; map mp; inline bool isprime(int x) { map::iterator it=mp.find(x); if(it!=mp.end()) return it->second; if(x!=2 && x%2==0) return 0; if(x==1) return 0; int d=3; while(d*d<=x) { if(x%d==0) return mp[x]=0; d+=2; } return mp[x]=1; } inline bool comb(int pos, int lim, int nr) { if(nr && !isprime(nr)) return 0; for(int i=pos;i<=lim;++i) { if(comb(i+1,lim,nr*10+numere[i])==0) return 0; } return 1; } void bkt(int pos, int x) { if(pos==9) return; for(int i=0+(pos!=0);i<4;++i) { numere[pos]=cf[i]; if(x*10+cf[i]>b) return; if(x*10+cf[i]>=a && comb(0,pos,0)) { ++nr; //cout<>a>>b; bkt(0,0); cout<