// yukicoder: No.375 立方体のN等分 (1) // 2019.5.10 bal4u #include #include long long comb(long long n) { long long min, s; int b, y; min = n-1, b = (int)sqrt((double)n); for (y = b; y >= 2; y--) { if (n%y == 0) return y + n/y - 2; } return min; } int main() { long long N, min, s; int a, b, x; scanf("%lld", &N); a = 1+(int)pow((double)N, 1.0/3), b = (int)sqrt((double)N); min = N-1;for (x = 2; x <= b; x++) if (N%x == 0) { if (x <= a) b = a; s = x-1 + comb(N/x); if (s < min) min = s; } printf("%lld %lld\n", min, N-1); return 0; }