/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 37ms 532.0 KiB
#3 Accepted 33ms 628.0 KiB
#4 Accepted 36ms 532.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
     
const long long mod = 10000007;
const long long INF = LLONG_MAX;
const int N = 1001000;

void solve () {
    long long n, k;
    cin >> k;

    k = 2LL * (k + 1);

    long long l = -1, r = 1e9;

    for (int i = 0; i < 100; i++) {
        long long m = l + (r - l) / 2;

        long long x = (m * m) + m;

        if (k <= x) {
            r = m;
            if (k == x) {
                break;
            }
        } else {
            l = m;
        }
    }
    if ((r * r) + r == k) {
        cout << "b";
    } else {
        cout << "a";
    }
} 
int main () {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); 

    long long t;
    cin >> t;

    while (t--) {
        solve();
        cout << "\n";
    }
    return 0;
}      

Information

Submit By
Type
Submission
Problem
P1223 C. Infinity Sequence
Contest
Happy New Year 2026
Language
C++17 (G++ 13.2.0)
Submit At
2026-01-06 16:14:51
Judged At
2026-01-06 16:14:51
Judged By
Score
100
Total Time
37ms
Peak Memory
628.0 KiB