/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 19ms 612.0 KiB
#3 Accepted 26ms 716.0 KiB
#4 Accepted 30ms 644.0 KiB

Code

                            /*in the name of almighty ALLAH*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int long long
#define endl '\n'
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
#define MOD2 987654319
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define sz(x) (int)x.size()

template <typename T> using pbds = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using multi_pbds = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

//***********************************START*******************************************//

void solve()
{
    int n; cin >> n;
    int lo = 2, hi = 5e8;
    char ch = 'a';

    while(lo <= hi){
        int mid = (lo + hi)/2;
        int sum = (mid*(mid+1) - 2 ) /2;
        if(sum == n){
            ch = 'b';
            break;
        }
        else if(sum < n) lo = mid+1;
        else hi = mid-1;
    }

    cout << ch << endl;
}

//***********************************END*********************************************//
int32_t main(){ fast

    int32_t t = 1, i;
      cin >> t;
    for(i = 1; i <= t; i++)
    {
       // cout << "Case " << i << ": ";
        solve();
    }
}

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 15:23:35
Judged At
2026-01-06 15:23:35
Judged By
Score
100
Total Time
30ms
Peak Memory
716.0 KiB