P1865 A% B problem
- Difficulty popularization/improvement-
Title background title is to attract you to come in the fact that the problem is still very water topic description
Number of interval mass
Input output Format input format:
Row of two integer queries N, Range m
The next n rows, two integers per line, l,r indicate the interval
Output format:
For each query output number T, such as L or r∉[1,m] output Crossing the line
Input and Output Sample input example # #:
2 51 32 6
Sample # # of output:
2Crossing the line
Description
"Data scope and conventions"
For 20% of data 1<=n<=10 1<=m<=10
For 100% data 1<=n<=1000 1<=m<=1000000-10^9<=l<=r<=10^9 1<=t<=1000000
#include <iostream>#include<cstdio>#include<cstring>using namespacestd;Long Longn,m,l,r,f[1000001],s[1000001],sum;intMain () {CIN>>n>>m; Memset (F,1,sizeof(f)); f[1]=0; for(intI=2; i<=m; i++)//Prime Sieve { if(F[i]) { for(intJ=i+i; j<=m; j+=i) f[j]=0; } } for(intI=1; i<=m; i++)//Number of characters between 1 and I { if(F[i]) sum++; S[i]=sum; } for(intI=1; i<=n; i++)//Output Processing{cin>>l>>R; if(r>m| | r<1|| l<1|| L>m) cout<<"Crossing the line"<<Endl; Else { if(F[l]) cout<<s[r]-s[l]+1<<Endl; Elsecout<<s[r]-s[l]<<Endl; } } return 0;}
A% B problem