5 条题解

  • 1
    @ 2025-4-20 12:09:49
    #include <bits/stdc++.h> 
    using namespace std; 
    int main(){ 
    	int n,i,j;
    	cin>>n;
    	for(i=2;i<=sqrt(n);i++){
    		if(n%i==0){
    		cout<<n/i;
    		break;
    		}
    	}
    	return 0;
    }
    
    • 1
      @ 2025-1-21 21:09:15

      质因数与质数自行查找

      题目分析

      其实这题只要用一个循环就够了,因为它是由两个不同质数相乘而来的,所以数据并不会爆,如果从小到大扫的话,则需要输出另一个质数。

      代码实现

      #include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; for(int i=2;i<=n;i++) if(n%i==0) { cout<<n/i<<endl; break; } return 0; }

      • -1
        @ 2025-2-22 17:48:22

        #include<bits/stdc++.h> using namespace std; int main(){

        int n,i,j;

        cin>>n;

        for(i=2;i<=sqrt(n);i++){

        if(n%i==0){
        
        	cout<<n/i;
        
        	break;
        
        }
        

        }

        return 0; }

        • -1
          @ 2025-1-21 16:44:28

          #include<bits/stdc++.h>

          using namespace std;

          int main(){

          int n,i,j;
          
          cin>>n;
          
          for(i=2;i<=sqrt(n);i++){
          
          	if(n%i==0){
          
          		cout<<n/i;
          
          		break;
          
          	}
          
          }
          
          return 0;
          

          }

          
          
          • -1
            @ 2025-1-21 14:52:37

            #include <bits/stdc++.h> using namespace std; bool su_shu(int n) { for (int i=2; i<n; i++) { if (n%i0) return false; } return true; } int main() { int n; cin>>n; for(int i=2; i<=ceil(n/2); i++) { if( n%i0 and su_shu(i)) { cout<<n/i<<' '; break; } } return 0; }

            • 1

            信息

            ID
            89
            时间
            1000ms
            内存
            128MiB
            难度
            1
            标签
            (无)
            递交数
            50
            已通过
            35
            上传者