2 solutions

  • 0
    @ 2024-11-30 16:00:41
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n;
        cin>>n;
        while(n--)
        {
            int x;
            cin>>x;
            map<int,int> h;
            for(int i=2;i<=x/i;i++)
            {
                while(x%i==0)
                {
                    h[i]++;
                    x/=i;
                }
            }
            if(x>1)
            {
                h[x]++;
            }
            for(auto it:h)
            {
                cout<<it.first<<" "<<it.second<<endl;
            }
            cout<<endl;
        }
        return 0;
    }
    
    • -1
      @ 2024-12-21 11:47:19
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
          int n;
          cin>>n;
          while(n--)
          {
              int x;
              cin>>x;
              map<int,int> h;
              for(int i=2;i<x/i;i++)
              {
                  while(x%i==0)
                  {
                      h[i]++;
                      x/=i;
                  }
              }
              if(x>1)
              {
                  h[x]++;
              }
              for(auto it:h)
              {
              	cout<<it.first<<" "<<it.second<<endl;
      		}
      		cout<<endl;
          }
          return 0;
      }
      
      • 1

      Information

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