We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c8eb84a commit a061c36Copy full SHA for a061c36
atcoder/abc144/C/main.cpp
@@ -0,0 +1,27 @@
1
+#include <bits/stdc++.h>
2
+
3
+using namespace std;
4
+using ll = int64_t;
5
+using ff = long double;
6
7
+ll solve(ll N) {
8
+ ll ans = N;
9
+ for (ll x = 1; x * x <= N; ++x) {
10
+ if (N % x == 0) {
11
+ ll y = N / x;
12
+ ans = min(ans, (x-1)+(y-1));
13
+ }
14
15
+ return ans;
16
+}
17
18
+int main() {
19
+ ios_base::sync_with_stdio(false);
20
+ cin.tie(0); cout.tie(0);
21
22
+ ll N;
23
+ cin >> N;
24
+ cout << solve(N) << endl;
25
26
+ return 0;
27
0 commit comments