3 条题解

  • 4
    @ 2023-12-3 16:45:07
    #include<iostream>
    using namespace std;
    
    int main(){
    	int n, cnt=0; cin>>n;
    	for(int t=2; t<n; t++){
    		// 判断 t 是不是素数
    		bool flag = 1;
    		for(int i=2; i<t; i++){
    			if(t%i==0){
    				flag = 0; break;
    			}
    		}
    		if(flag==1) {// 是素数 
    			cout<<t<<" ";
    			cnt ++;
    			if(cnt%5==0) cout<<endl;// 5 10 15 20
    		}
    	}
    	return 0;
    } 
    
    
    • 4
      @ 2023-12-3 16:44:06
      #include<iostream>
      using namespace std;
      
      int main(){
      	int n, cnt=0; cin>>n;
      	for(int t=2; t<n; t++){
      		// 判断 t 是不是素数
      		bool flag = 1;
      		for(int i=2; i<t; i++){
      			if(t%i==0){
      				flag = 0; break;
      			}
      		}
      		if(flag==1) {// 是素数 
      			cout<<t<<" ";
      			cnt ++;
      			if(cnt%5==0) cout<<endl;// 5 10 15 20
      		}
      	}
      	return 0;
      }
      
      
    • -12
      @ 2023-11-12 16:55:52

      #include<bits/stdc++.h> using namespace std; int main(){ int n,j=0; bool s=0; cin>>n; for(int i=2;i<n;i++){ s=0; for(int t=2;t<=i-1;t++){ if(i%t0){ s=1; break; } } if(!s){ if(j%50) cout<<endl; cout<<i<<" "; j++; } } return 0; }

      • 1

      信息

      ID
      25
      时间
      1000ms
      内存
      16MiB
      难度
      6
      标签
      递交数
      181
      已通过
      58
      上传者