Skip to content

Commit a061c36

Browse files
committed
atcoder/abc144C
1 parent c8eb84a commit a061c36

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

atcoder/abc144/C/main.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)