B. 3-palindrome
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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
Note

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


————————————————————————————————————
题目给出一个n,要求构造出一个只含abc的字符串,要求没有长度为3的回文子串且c尽可能少
思路构造aabbaabbaabbaa这样的即可

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define inf 0x3f3f3f3f
#define LL long long int main()
{
int n;
scanf("%d",&n);
int flag=0;
int cnt=0;
for(int i=1; i<=n; i++)
{
if(flag==0) printf("a");
else printf("b");
cnt++;
if(cnt==2)
cnt=0,flag^=1;
}
printf("\n");
return 0;
}

Codeforces805B. 3-palindrome 2017-05-05 08:33 156人阅读 评论(0) 收藏的更多相关文章

  1. 第十二届浙江省大学生程序设计大赛-May Day Holiday 分类: 比赛 2015-06-26 14:33 10人阅读 评论(0) 收藏

    May Day Holiday Time Limit: 2 Seconds Memory Limit: 65536 KB As a university advocating self-learnin ...

  2. c#委托和事件(下) 分类: C# 2015-03-09 08:42 211人阅读 评论(0) 收藏

    C#中的委托和事件(下) 引言 如果你看过了 C#中的委托和事件 一文,我想你对委托和事件已经有了一个基本的认识.但那些远不是委托和事件的全部内容,还有很多的地方没有涉及.本文将讨论委托和事件一些更为 ...

  3. HDU6024 Building Shops 2017-05-07 18:33 30人阅读 评论(0) 收藏

    Building Shops                                                             Time Limit: 2000/1000 MS ...

  4. .net 实现Office文件预览 Word PPT Excel 2015-01-23 08:47 63人阅读 评论(0) 收藏

    先打个广告: .Net交流群:252713569 本人QQ :524808775 欢迎技术探讨, 近期公司要求上传的PPT和Word都需要可以在线预览.. 小弟我是从来没有接触过这一块的东西 感觉很棘 ...

  5. 基于命令行编译打包phonegap for android应用 分类: Android Phonegap 2015-05-10 10:33 73人阅读 评论(0) 收藏

    也许你习惯了使用Eclipse编译和打包Android应用.不过,对于使用html5+js开发的phonegap应用,本文建议你抛弃Eclipse,改为使用命令行模式,绝对的快速和方便. 一直以来,E ...

  6. walk around by The provided App differs from another App with the same version and product ID 分类: Sharepoint 2015-07-05 08:14 4人阅读 评论(0) 收藏

    'm currently developing a SharePoint 2013 application. After a few deployments via Visual Studio, I ...

  7. hdu 1050 (preinitilization or postcleansing, std::fill) 分类: hdoj 2015-06-18 11:33 34人阅读 评论(0) 收藏

    errors, clauses in place, logical ones, should be avoided. #include <cstdio> #include <cstr ...

  8. hdu 1047 (big integer sum, fgets or scanf, make you func return useful infos) 分类: hdoj 2015-06-18 08:21 39人阅读 评论(0) 收藏

    errors made, boundary conditions, <= vs < , decreasing vs increasing , ++, –, '0'/'1' vs 0/1 p ...

  9. A simple problem 分类: 哈希 HDU 2015-08-06 08:06 1人阅读 评论(0) 收藏

    A simple problem Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) To ...

随机推荐

  1. Java学习 第二节

    1.非递归求第四十个斐波那契数 package test; public class fibonacci2 { public static void main(String arg[]) { ; ; ...

  2. 2基本类型数组和枚举类型——重拾Java

    2.1 标识符和关键字 2.1.1标识符 标识符:用来标志类名.变量名.方法名.类型名.数组名.文件名的有效字符序列称为标识符.简单地说,标识符就是一个名字. Java关于标识符的语法规则 标识符由字 ...

  3. spark 创建稀疏向量和矩阵

    http://blog.csdn.net/canglingye/article/details/41316193 [相互转换]:http://stackoverflow.com/questions/3 ...

  4. python并行编程

    一.编程思想 并行编程的思想:分而治之,有两种模型 1.MapReduce:将任务划分为可并行的多个子任务,每个子任务完成后合并得到结果 例子:统计不同形状的个数. 先通过map进行映射到多个子任务, ...

  5. 绘制pathway富集散点图

    本文转载自http://www.omicshare.com/forum/forum.php?mod=viewthread&tid=146&extra=page%3D1%26filter ...

  6. Photoshop和Halcon中的极坐标变换

    极坐标想必学过高中数学的人都听过,一般的坐标系中用(x, y)值来描述一个点的位置,而在极坐标系中,则使用到原点的距离ρ和夹角θ来描述该点的位置. 我很早就接触了Photoshop,知道Photosh ...

  7. css设置超出部分文档隐藏(在table标签中不好使解决方案在下)

    css设置: .text-over{overflow: hidden;white-space: nowrap;text-overflow: ellipsis;cursor: pointer} div设 ...

  8. yaf框架安装配置

    YAF中文文档:http://www.laruence.com/manual/index.html 1 YAF框架是用C开发的,属于PHP的扩展框架: 2 YAF的性能相对于源生PHP,性能只降低不到 ...

  9. .net体系与java体系

    对于.NET Framework体系结构,参考了"你必须知道的.NET"并”借用“别人的经典体系结构图从宏观上说明一下我的理解. 图1 简单的说下几个名词: CLR: 通用语言运行 ...

  10. DNA binding motif比对算法

    DNA binding motif比对算法 2012-08-31 ~ ADMIN 之前介绍了序列比对的一些算法.本节主要讲述motif(有人翻译成结构模式,但本文一律使用基模)的比对算法. 那么什么是 ...