CF805B.3-palindrome

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In the beginning of the new year Keivan decided to reverse his name. He doesn't like palindromes, so he changed Naviek to Navick.

He is too selfish, so for a given n he wants to obtain a string of n characters, each of which is either 'a', 'b' or 'c', with no palindromes of length 3 appearing in the string as a substring. For example, the strings "abc" and "abca" suit him, while the string "aba" doesn't. He also want the number of letters 'c' in his string to be as little as possible.

新年伊始,凯文决定将自己的名字反转。他不喜欢回文串,因此将 “Naviek” 改为了 “Navick”。

他非常自私,因此对于给定的正整数 nn,他希望构造一个长度为 nn 的字符串,其中每个字符只能是 'a'、'b' 或 'c',且该字符串中不能出现任何长度为 3 的回文子串。例如,字符串 "abc" 和 "abca" 符合要求,而 "aba" 不符合。此外,他还希望字符串中字母 'c' 的个数尽可能少。

输入格式

The first line contains single integer n (1 ≤ n ≤ 2·105) — the length of the string.

第一行包含一个整数 nn(1≤n≤2⋅1051 \leq n \leq 2 \cdot 10^5)—— 字符串的长度。

输出格式

Print the string that satisfies all the constraints.

If there are multiple answers, print any of them.

输出满足所有约束条件的字符串。

如果存在多个答案,输出其中任意一个即可。

输入输出样例

  • 输入#1

    2

    输出#1

    aa
  • 输入#2

    3

    输出#2

    bba

说明/提示

A palindrome is a sequence of characters which reads the same backward and forward.

回文是一个字符序列,它正读和反读都相同。

输入解题思路,AI测评打分。不知道怎么写?

首页