K:
以nunhehheh开头,a结尾的为合法串。构建一个串,使其字串合法的种数为给定的数。
思路:aa能构成3种,aaa能构成7种即2^n - 1种贡献,先把nunhehhe定下来(少一个h),h后面有i个a,就能有2^i - 1 种贡献,再在最后一个a前面加一个h,加一种贡献,这样就能有2^i种贡献。
eg:n = 7, 7 >= 2^2,在第二个a前加一个h,在第一个a前加一个h,贡献为2^2 - 1 + 1 = 4, n -= 4;
3 >= 2^1,在第一个a前加一个h,在第一个a前加一个h,贡献为2^1 - 1 + 1 = 2, n -= 2;
还剩1, 在第一个a前加一个h,贡献为1,n-=1;
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PII pair<int , int>
const int N = 1e6 + 10;
const int mod = 1e9 + 7, inf = 0x3f3f3f3f;
int pow2[32], cnt[32];
void init(){
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
//预处理2的i次方
pow2[0] = 1;
for(int i = 1; i < 32; i ++){
pow2[i] = pow2[i - 1] * 2;
}
}
void solve(int n){
memset(cnt, 0, sizeof cnt);
//cout << n << ' ' << cnt[31] << endl;
for(int i = 31; i > 0; i --){
if(n >= pow2[i]){
cnt[i] ++;
cnt[1] ++;
n -= pow2[i];
}
}
if(n & 1) cnt[1] ++;
cout << "nunhehhe";
for(int i = 31; i >= 1; i --){
for(int j = 0; j < cnt[i]; j ++){
cout << 'h';
}
cout << 'a';
}
cout << endl;
}
signed main()
{
init();
int q;
cin >> q;
while(q --){
int n;
cin >> n;
solve(n);
}
return 0;
}