Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. vector<pair<int,int>> fact(int n) {
  2.     vector<pair<int,int>> result;
  3.     for (int p = 2; p*p <= n; ++p) {
  4.         if (n % p == 0) {
  5.             result.emplace_back(p, 0);
  6.             while (n % p == 0) {
  7.                 ++result.back().second;
  8.                 n /= p;
  9.             }
  10.         }
  11.     }
  12.     if (n > 1) {
  13.         result.push_back(n, 1);
  14.     }
  15.     return result;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement