Accepted
Code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n;
cin >> n;
int cnt = 0;
// only need to iterate while k*k <= n
for (long long k = 1; k * k <= n; ++k) {
ll sq = k * k;
ll conq = k * (k + 1);
if (sq <= n) cnt++;
if (conq <= n) cnt++;
}
cout << cnt << endl;
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1191 A. Balanced Product
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2025-04-06 11:38:21
- Judged At
- 2025-04-06 11:38:21
- Judged By
- Score
- 100
- Total Time
- 2ms
- Peak Memory
- 540.0 KiB