/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 584.0 KiB
#2 Accepted 1ms 540.0 KiB
#3 Accepted 1ms 540.0 KiB
#4 Accepted 1ms 540.0 KiB
#5 Accepted 1ms 556.0 KiB
#6 Accepted 1ms 328.0 KiB

Code

#include <iostream>
using namespace std;

int main() {
    long long n;
    cin >> n;
    long long count = 0;

    for (long long a = 1; ; a++) {
        long long x1 = a * a;
        long long x2 = a * (a + 1);

        if (x1 <= n) count++;
        if (x2 <= n) count++;

        // If both are greater than n, no further balanced numbers are possible
        if (x1 > n && x2 > n) break;
    }

    cout << count << endl;
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1191 A. Balanced Product
Language
C++17 (G++ 13.2.0)
Submit At
2025-06-14 05:56:47
Judged At
2025-06-14 05:56:47
Judged By
Score
100
Total Time
1ms
Peak Memory
584.0 KiB