Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (k > 0) {
- for (int p1 = 1; p1<=sqrt(k); p1++) {
- if (k % p1 == 0 && (k / p1 + p1) % 2 == 0) {
- ans = min(ans, (k/p1 + p1) / 2);
- }
- }
- }
- else {
- k = -k;
- for (int p1 = 1; p1*p1 <= k; p1++) {
- if (k % p1 == 0 && (k / p1 - p1) % 2 == 0) {
- ans = min(ans, (k / p1 - p1) / 2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement