Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<vector>
- typedef long long int ll;
- using namespace std;
- bool sieve[1000010];
- int main()
- {
- vector<ll> vec;
- int cnt = 0;
- for(ll i = 2 ; i <= 1000000 ; i ++){
- if(!sieve[i]){
- vec.push_back(i*i);
- for(ll j = i*2; j <= 1000000 ; j += i){
- sieve[j] = true;
- }
- cnt++;
- }
- }
- ll L,R;
- scanf("%lld %lld",&L,&R);
- bool check = false;
- for(int i = 0 ; i < vec.size() ; i ++){
- if(L <= vec[i] && vec[i] <= R){
- printf("%lld ",vec[i]);
- check = true;
- }
- }
- if(!check)printf("-1");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment