3 solutions

  • 1
    @ 2025-12-14 13:48:31
    #include<bits/stdc++.h>
    using namespace std;
    int n;
    int main(){
    	cin>>n;
    	while(n--){
    		int a;
    		cin>>a;
    		map<int,int> h;
    		for(int i=2;i*i<=a;i++){
    			while(a%i==0){
    				h[i]++;
    				a/=i;
    			}
    		}
    		if(a>1){
    			h[a]++;
    		}
    		for(auto it:h) cout<<it.first<<' '<<it.second<<endl;
    		 cout<<endl;
    	}
    
    
    	return 0;
    }
    
    

    Information

    ID
    178
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    3
    Tags
    # Submissions
    135
    Accepted
    30
    Uploaded By