Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- int main() {
- ios_base::sync_with_stdio(false);
- ll x, n;
- cin >> x >> n;
- for(ll i = 0; i < n; i++) {
- ll sqr = sqrt(x);
- ll max_divisor = 1;
- for(ll j = 2; j <= sqr; j++) {
- if(x % j == 0) {
- max_divisor = max(max_divisor, j);
- if(x / j != j) {
- max_divisor = max(max_divisor, x / j);
- }
- break;
- }
- }
- x += max_divisor;
- }
- cout << x << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement