Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define INF 1000010000
- #define nl '\n'
- typedef long long ll;
- inline bool prime(int d){
- for( int i = 2 ; i*i <= d ; ++i )
- if( !(d % i) ) return 0;
- return 1;
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.precision(0);
- vector<int> a(1000010 , 0);
- vector<int> f(1000010 , 0);
- a[0] = 0;
- a[1] = 0;
- a[2] = 1;
- f[2] = 1;
- bool ck;
- for( int i = 3 ; i <= 1000005 ; ++i ){
- ck = prime(i);
- a[i] = a[i - 1] + ck;
- f[i] = f[i - 1];
- if(ck){
- if(!((i - 1) % 4))
- ++f[i];
- }
- }
- int u , v;
- for(;;){
- cin >> u >> v;
- if(u == -1 && v == -1) return 0;
- cout << u << " " << v << " " ;
- cout << a[max(v,0)] - a[max(u - 1,0)] << " " ;
- cout << f[max(v,0)] - f[max(u - 1,0)] << nl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement