Advertisement
Guest User

Untitled

a guest
Nov 14th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. ifstream fin("test.in");
  7. ofstream fout("test.out");
  8.  
  9. int cmm_factor_prim(int n) {
  10.     int div = -1, mult6 = 6;
  11.     while (mult6 - 1 <= n) {
  12.         if (n % (mult6 - 1) == 0) {
  13.             div = mult6 - 1;
  14.             n /= div;
  15.         }
  16.         if (n % (mult6 + 1) == 0) {
  17.             div = mult6 + 1;
  18.             n /= div;
  19.         }
  20.         mult6 += 6;
  21.     }
  22.     return n;
  23. }
  24.  
  25. int main() {
  26.     int n;
  27.     fin >> n;
  28.     fout << cmm_factor_prim(n) << '\n';
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement