Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Bismillahir Rahmanir Rahim
- /******Harun Or Rashid******/
- /***********Template Starts Here***********/
- #include<iostream>
- #include<cstdio>
- #include<cstring>
- #include<cmath>
- #include<cctype>
- #include<cstdlib>
- #include<cassert>
- #include<string>
- #include<vector>
- #include<set>
- #include<stack>
- #include<queue>
- #include<map>
- #include<algorithm>
- using namespace std;
- #define MEM(a,b) memset(a,b,sizeof(a))
- #define CLR(a) memset(a,0,sizeof(a))
- #define MAX(a,b) ((a)>(b)?(a):(b))
- #define MIN(a,b) ((a)>(b)?(b):(a))
- #define ABS(a) ((a)>0? (a):(-(a)))
- #define SQ(a) ((a)*(a))
- #define SZ(a) (int)a.size()
- #define FORN(i,n) for(i=1;i<=n;i++)
- #define FORAB(i,a,b) for(i=a;i<=b;i++)
- #define ALL(V) V.begin(),V.end()
- #define pb(a) push_back(a)
- #define pr(a) cout<<a<<endl
- #define SQR(a) ((a)*(a))
- #define pf printf
- #define sf scanf
- #define swap(a,b) (a ^= b, b ^= a, a ^= b)
- #define PI acos(-1)
- #define x first
- #define y second
- #define eps 1e-7
- typedef int D;
- typedef long long int LLD;
- typedef unsigned long long int LLU;
- typedef vector<D> VI;
- typedef set<D> SI;
- typedef vector<D>::iterator Viti;
- /***********Template Ends Here***********/
- int main()
- {
- int T,m,n,cnt;
- cin>>T;
- while(T--)
- {
- cin>>m>>n;
- bool prime[n+1];
- int i,j;
- memset(prime,true,sizeof prime);
- prime[0]=prime[1]=false;
- for(i=4; i<=n; i+=2) prime[i]=false;
- for(i=3; i*i<=n; i+=2)
- if(prime[i])
- for(j=i*i; j<=n; j+=i+i)
- prime[j]=false;
- cnt=0;
- for(i=0; i<=n; i++)
- if(prime[i]==false)
- if(i>=m)
- {
- int x=i;
- while(x)
- {
- if(x%10==7)
- {
- cnt++;
- break;
- }
- x/=10;
- }
- }
- if(cnt)
- cout<<cnt<<endl;
- else cout<<"-1"<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement