1 solutions

  • 0
    @ 2024-12-4 19:37:03

    C++ :

    #include<iostream>
    #include<cstring>
    using namespace std;
    bool a[10005];
    int main(){
    	memset(a,true,sizeof(a));
    	for (int i=2; i<=100; i++)
    		if (a[i])
    			for (int j=2*i; j<=10000; j+=i)
    				a[j]=false;
    	int t=0;
    	for (int i=2; i<=10000; i++)
    		if (a[i]){
    			cout<<i;
    			t++;
    			if (t%10==0) cout<<endl;
    			else cout<<" ";
    		}
    	cout<<endl;
    	return 0;
    }
    
    • 1

    Information

    ID
    2267
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By