Guest User

numero_primo

a guest
Apr 5th, 2018
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3.  
  4. long int N, i, j, lt, rt;
  5. ifstream in("input.txt");
  6. ofstream out("output.txt");
  7.  
  8. inline bool primary(long int n) { return (n%2!=0 && n%3!=0); }
  9.  
  10. bool resolve() {
  11.     for(i = 1; i <= N/2; i++) {
  12.         for(j = 1; j <= N/2 && i*j <= N; j++) {
  13.             if(primary(i) && primary(j)) {
  14.                 if(i * j == N) {
  15.                     lt = i, rt = j;
  16.                     return true;
  17.                 }
  18.             }
  19.         }
  20.     }
  21.     return false;
  22. }
  23.  
  24. int main() {
  25.     in >> N;
  26.     if(!resolve())
  27.         out << -1;
  28.     else
  29.         out << lt << ' ' << rt << endl;
  30.     in.close();
  31.     out.close();
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment