Accepted
Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(x) (x).begin(), (x).end()
#define f(i, n) for (int i = 0; i < n; i++)
#define trace(x) cerr << #x << ": " << x << '\n'
int sq(int n)
{
int x = sqrt(n);
while (x * x < n)
x++;
while (x * x > n)
x--;
return x;
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
int x = sq(n);
int ans = 2 * x - 1;
ans += (x * (x + 1) <= n);
cout << ans << '\n';
}
Information
- Submit By
- Type
- Submission
- Problem
- P1191 A. Balanced Product
- Contest
- Brain Booster #10
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2025-06-13 15:33:42
- Judged At
- 2025-06-13 15:33:42
- Judged By
- Score
- 100
- Total Time
- 1ms
- Peak Memory
- 532.0 KiB