当前位置:   article > 正文

CF411div2 B. 3-palindrome_n the beginning of the new year keivan decided to

n the beginning of the new year keivan decided to reverse his name. he doesn
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.

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

Print the string that satisfies all the constraints.

If there are multiple answers, print any of them.

Examples
input
2
output
aa
input
3
output

bba



只要没有三个是回文的 直接输出aabbaabbaabb这个形式的 这个任意三个数没有回文 而且没有c

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <bits/stdc++.h>
  4. #define mod 1000000007
  5. #define ll long long
  6. using namespace std;
  7. int main()
  8. {
  9. int n;
  10. cin>>n;
  11. int k=1;
  12. for(int i=0;i<n;i++){
  13. if(i%2==0)k*=-1;
  14. if(k==1)printf("%c",'b');
  15. else printf("%c",'a');
  16. }
  17. return 0;
  18. }



声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号