1 comments

  • @ 2024-3-8 21:32:47
    #include<bits/stdc++.h>
    using namespace std;
    bool nums[1000000];
    void aishai_pf(int n){
    	int i=2;
    	while(i<=n){
    		for(int j=i+1;j<=n;j++){
    			if(j%i==0) nums[j]=true;
    		}
    		cout<<i<<endl;
    		i++;
    		while(nums[i]) i++;
    	}
    }
    void aishai_zg(int n){
    	for(int i=2;i<=n;i++) nums[i]=true;
    	int i=2;
    	while(i<=n){
    		if(nums[i]==true){
    			for(int j=i+1;j<=n;j++){
    				if(j%i==0) nums[j]=false;
    			}
    			cout<<i<<endl;
    		}
    		i++;
    	}
    }
    int n;
    int main(){
    	while(true){
    		cin>>n;
    		aishai_zg(n);
    	}
    }
    
  • 1

Information

ID
184
Time
1000ms
Memory
256MiB
Difficulty
7
Tags
# Submissions
162
Accepted
36
Uploaded By