D. Diane

63 篇文章 1 订阅
11 篇文章 0 订阅

题意:
让你构造一个长度为n的字符串,使得每一个子串都出现奇数次。
思路:
死活构造不出来,只知道每一个字母只能出现奇数次,有一个奇妙的性质没有挖掘到,就是相邻长度l和l+1的连续的字母两个一块构造的话就能出现奇数次,那么讨论讨论就行了,把两个字符串分开用别的字母就可以。注意1的特判。

// Problem: C. Mikasa
// Contest: Codeforces - Codeforces Round #735 (Div. 2)
// URL: https://codeforces.com/contest/1554/problem/C
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
typedef pair<int,int> pii;
#define int long long
int n,m;
bool check(int x)
{
	int tt=0;
	int res=0;
	for(int i=31;i>=0;i--)
	{
		if(n>>i&1)	{res+=(1ll<<i);continue;}
		else
		{
			if(tt+(1ll<<i)<=x)	tt+=(1ll<<i),res+=(1ll<<i);
		}
	}
	return res>m;
}
signed main()
{	
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin >> n;
		string s;
		if(n==1)
		{
			cout<<"a"<<endl;
			continue;
		}
		if(n%2==0)	{
			for(int i=0;i<n/2-1;i++)
			s+='a';
			s+='b';
			for(int i=0;i<n/2;i++)
			s+='a';
		}
		else{
			for(int i=0;i<n/2-1;i++)
			s+='a';
			s+='c';
			s+='b';
			for(int i=0;i<n/2;i++)
			s+='a';
		}
		cout<<s;
		cout<<endl;
	}
	
}
/**
* In every life we have some trouble
* When you worry you make it double
* Don't worry,be happy.
**/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值