Advertisement
ivangarvanliev

Untitled

Jun 2nd, 2024
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int c;
  7.     cin >> c;
  8.  
  9.     for (int i = 0; i < c; ++i) {
  10.         int n;
  11.         cin >> n;
  12.  
  13.         int p = 0;
  14.         for (int m = 2; m <= 100000; ++m) {
  15.             if (n % m == 0) {
  16.                 p = m;
  17.                 break;
  18.             }
  19.         }
  20.  
  21.         if (p == 0) {
  22.             p = n;
  23.         }
  24.  
  25.         cout << n / p << " " << n - (n / p) << endl;
  26.     }
  27.  
  28.     return 0;
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement