Advertisement
Josif_tepe

Untitled

Apr 4th, 2023
832
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. typedef long long ll;
  5. int main() {
  6.     ios_base::sync_with_stdio(false);
  7.     ll x, n;
  8.     cin >> x >> n;
  9.    
  10.     for(ll i = 0; i < n; i++) {
  11.         ll sqr = sqrt(x);
  12.         ll max_divisor = 1;
  13.         for(ll j = 2; j <= sqr; j++) {
  14.             if(x % j == 0) {
  15.                 max_divisor = max(max_divisor, j);
  16.                 if(x / j != j) {
  17.                     max_divisor = max(max_divisor, x / j);
  18.                 }
  19.                 break;
  20.             }
  21.         }
  22.         x += max_divisor;
  23.     }
  24.     cout << x << endl;
  25.    
  26.     return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement