Codeforces Round #629 (Div. 3) B

#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <cmath>
#include <algorithm>
#define inf 0x3f3f3f3f
#define sd(a) scanf("%d",&a)
#define mem0(a) memset(a,0,sizeof(a))
typedef long long ll;
const int mod = 998244353;
const int maxn = 1e5+10;
char c[maxn];
int cur,tar;
using namespace std;



int main()
{
    
    
    int n,k,t;
    sd(t);
    while(t--)
    {
    
    
        sd(n),sd(k);
        ll pos1,pos2;
        for(ll i=1;i<=n;i++){
    
    
			pos1=i*(i-1)/2;
			if(pos1>=k){
    
    
				pos1=i-1;
				break;
			}
		}
        pos2 = k - (pos1*(pos1 - 1)>>1) - 1;
		pos1=n-pos1-1;
		pos2=n-pos2-1;
        for(ll i = 0;i < n;i++)
        {
    
    
            if(i == pos1 ||i == pos2)
                cout<<'b';
            else
                cout<<'a';
        }
        cout<<endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_42937838/article/details/105276906