先看几个例子 满足条件 满足条件 满足条件 满足条件,此时你肯定一定有点思路了,这里直接给出结论如果有个末尾有的情况那么最少会产生个字串,为什么说最少呢,因为我们可以在这个基础上添加使得可以构造3,4,5,7,8,9,10,11……等任意个 举个例子,如果我们要构造的是7我们只需要在的基础上在开头两个后面添加一个即可,所以对于任意的,我们先求出,然后再求还需要多少个,然后按照这样的构造方法构造字符串即可。
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
# include<iostream>
# include<iomanip>
# include<algorithm>
# include<cmath>
# include<cstdio>
# include<set>
# include<stack>
# include<queue>
# include<map>
# include<string>
# include<cstring>
# define eps 1e-9
# define fi first
# define se second
# define ll long long
# define int ll
// cout<<fixed<<setprecision(n)
using namespace std;
typedef unsigned long long ull;
typedef pair<int,int > PII;
const int mod=1e9+7;
const int MAX=1e5+10;
const int Time=86400;
const int X=131;
const int inf=0x3f3f3f3f;
const double PI = 1e-4;
double pai = 3.14159265358979323846;
int T,n,dp[MAX],pre[2][15];
void solve(){
string s;
cin >> n ;
if(n == 1){ //特判n=1 因为我们默认构造最小是yycc
cout<<"3\nyyc\n";
return;
}
int k = sqrt(n) + 1;
if((k-1) * k > n ) k--; //总共需要多少个y
int x = k - 2; //除了开头2个y还需要多少个y
int m = n - (k * k - k);//除了末尾两个c中间还需要多少个c
s = "yy";
for(int i = 0 ; i < m ; i ++ ) s += 'c';
for(int i = 0 ; i < x ; i ++ ) s += 'y';
s += "cc";
cout<<s.size() <<"\n" << s<<"\n";
}
signed main(){
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> T;
while(T--){
solve();
}
return 0;
}