D. Diane
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
You are given an integer nn. Find any string ss of length nn consisting only of English lowercase letters such that each non-empty substring of ss occurs in ss an odd number of times. If there are multiple such strings, output any. It can be shown that such string always exists under the given constraints.
A string aa is a substring of a string bb if aa can be obtained from bb by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.
Input
The first line contains a single integer tt (1≤t≤5001≤t≤500) — the number of test cases.
The first line of each test case contains a single integer nn (1≤n≤1051≤n≤105).
It is guaranteed that the sum of nn over all test cases doesn't exceed 3⋅1053⋅105.
Output
For each test case, print a single line containing the string ss. If there are multiple such strings, output any. It can be shown that such string always exists under the given constraints.
Example
input
Copy
4 3 5 9 19
output
Copy
abc diane bbcaabbba youarethecutestuwuu
Note
In the first test case, each substring of "abc" occurs exactly once.
In the third test case, each substring of "bbcaabbba" occurs an odd number of times. In particular, "b" occurs 55 times, "a" and "bb" occur 33 times each, and each of the remaining substrings occurs exactly once.
---------------------------------------------------------------------------------------------------------------------------------
首先猜测只需要两种字母,打表发现偶数是满足的,猜测奇数需要3种字母,打表发现也是满足的。直接找规律即可。特判1,否则白WA一次
# include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main ()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
if(n==1)
{
cout<<'a'<<endl;
continue;
}
if(n%2==0)
{
for(int i=1;i<=n/2;i++)
{
cout<<'a';
}
cout<<'b';
for(int i=n/2+2;i<=n;i++)
{
cout<<'a';
}
cout<<endl;
}
else
{
for(int i=1;i<=n/2;i++)
{
cout<<'a';
}
cout<<'b';
for(int i=n/2+2;i<n;i++)
{
cout<<'a';
}
cout<<'c';
cout<<endl;
}
}
return 0;
}