D. Diane- 构造 -打表

文章描述了一个在Codeforces平台上的编程问题,要求找到一个由小写字母组成的字符串,其所有非空子串在原字符串中出现的次数为奇数。给出了样例输入和输出,并提供了一个简单的C++解决方案,该方案特别处理了字符串长度为1的情况,并依据字符串长度的奇偶性构建满足条件的字符串。
摘要由CSDN通过智能技术生成

Problem - D - Codeforces

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;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qinsanma and Code

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值