1 条题解

  • 0
    @ 2025-10-10 19:52:16

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    
    int n,c,ma;
    map<int,int> m;
    map<int,int>::iterator it;
    int main() {
    //	for(int i = 10000;i>=9000;i--){
    //		bool f = true;
    //		for(int j = 2;j <= sqrt(i);j++){
    //			if(i % j == 0){
    //				f = false;
    //				break;
    //			}
    //		}
    //		
    //		if(f == true){
    //			cout<<i<<endl;
    //		}
    //	}
    	cin>>n;
    	
    	if(n == 1){
    		cout<<"1=1";
    		return 0;
    	}
    	
    	cout<<n<<"=";
    	for(int i = 2;i <= sqrt(n);i++){
    		while(n % i == 0){
    			m[i]++;
    			n = n / i;
    			ma = i;
    		}
    	}
    	
    	if(n > 1){
    		m[n]++;	
    		ma = n;
    	} 
    	
    	for(it = m.begin();it != m.end();it++){
    		cout<<it->first;
    		if(it->second > 1) cout<<"^"<<it->second;
    		
    		if(it->first != ma) cout<<"*"; 
    	}
    	return 0;
    }
    
    
    • 1

    信息

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