Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <cstring>
- #include <cmath>
- #define ll long long
- using namespace std;
- bool esPrimo(const ll &n)
- {
- ll lim = sqrt(n);
- for(ll i = 2; i <= lim; i++)
- if(!(n % i))
- return false;
- return true;
- }
- int main()
- {
- ll n, r = 0;
- cin >> n;
- if(esPrimo(n))
- {
- cout << "1\n";
- }
- else
- {
- for(ll i = 2; i <= sqrt(n); i++)
- {
- if(esPrimo(i) && (!(n % i)))
- {
- r = i;
- break;
- }
- }
- cout << (1 + ((n - r) / 2)) << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement