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,

我们需要用‘a’ ‘b’ ‘c’组成字符串使其无三字子串,‘c’尽可能少。

c尽可能少的话我们就不用c了,

循环abba即可

附AC代码:

 #include<bits/stdc++.h>
using namespace std; int main(){
int n;
cin>>n;
int x=n/;
int y=n%;
for(int i=;i<x;i++){
cout<<"abba";
}
if(y==)
cout<<"a"<<endl;
else if(y==)
cout<<"ab"<<endl;
else if(y==)
cout<<"abb"<<endl;
return ;
}

CF-805B的更多相关文章

  1. ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'

    凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...

  2. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  3. cf Round 613

    A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...

  4. ARC下OC对象和CF对象之间的桥接(bridge)

    在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...

  5. [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现

    1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...

  6. CF memsql Start[c]UP 2.0 A

    CF memsql Start[c]UP 2.0 A A. Golden System time limit per test 1 second memory limit per test 256 m ...

  7. CF memsql Start[c]UP 2.0 B

    CF memsql Start[c]UP 2.0 B B. Distributed Join time limit per test 1 second memory limit per test 25 ...

  8. CF #376 (Div. 2) C. dfs

    1.CF #376 (Div. 2)    C. Socks       dfs 2.题意:给袜子上色,使n天左右脚袜子都同样颜色. 3.总结:一开始用链表存图,一直TLE test 6 (1)如果需 ...

  9. CF #375 (Div. 2) D. bfs

    1.CF #375 (Div. 2)  D. Lakes in Berland 2.总结:麻烦的bfs,但其实很水.. 3.题意:n*m的陆地与水泽,水泽在边界表示连通海洋.最后要剩k个湖,总要填掉多 ...

  10. CF #374 (Div. 2) D. 贪心,优先队列或set

    1.CF #374 (Div. 2)   D. Maxim and Array 2.总结:按绝对值最小贪心下去即可 3.题意:对n个数进行+x或-x的k次操作,要使操作之后的n个数乘积最小. (1)优 ...

随机推荐

  1. 【每日Scrum】第四天(4.25) TD学生助手Sprint2站立会议

    站立会议 组员 昨天 今天 困难 签到 刘铸辉 (组长) 和小楠重写架构,使代码更加简洁,并增加了几个界面 今天增加了几个页面的子菜单,然后设计了几个要用的界面 遇到的困难是,菜单的事件处理真是神一样 ...

  2. Android Studio 那些事|Activity文件前标识图标显示为 j 而是 c

    问题:Activity文件前标识图标显示为 j 而是 c 的图标,或是没有显示,并且自己主动提示不提示 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/fo ...

  3. 深度解析开发项目之 03 - enum的使用

    深度解析开发项目之 03 - enum的使用 01 - 在#import和@interface之间定义typedef enum 注意: 默认是0,1,2,3 02 - 定义可以操作的数据类型的属性 0 ...

  4. SpringSecurity学习笔记(一):搭建最简单的SpringSecurity应用

    学习过程参考自:http://www.mossle.com/docs/auth/html/pt01-quickstart.html 一.搭建Maven项目: 所需引用的jar包如下: pom.xml文 ...

  5. UniversalImageLoader 学习

    http://www.tuicool.com/articles/zIRNN3z http://www.cnblogs.com/avenwu/archive/2013/05/03/3058468.htm ...

  6. PostgreSQL与MySQL比較

    特性 MySQL PostgreSQL 实例 通过执行 MySQL 命令(mysqld)启动实例. 一个实例能够管理一个或多个数据库.一台server能够执行多个 mysqld 实例.一个实例管理器能 ...

  7. 什么是 AQS ?

    1.什么是AQS? AQS是英文单词AbstractQueuedSynchronizer的缩写,翻译过来就是队列同步器. 它是构建锁或者其他同步组件的基础框架(如ReentrantLock.Reent ...

  8. mybatis入门(八)

    mybatis入门---更新和删除 <!-- 删除用户 --> <delete id="deleteUser" parameterType="java. ...

  9. php遍历统计文件目录和文件

    function total($dirname, &$dirnum, &$filenum){ $dir=opendir($dirname); readdir($dir)."& ...

  10. LwIP移植uCos+stm32f407

    LwIP同操作系统一起工作的时候模型如下: 1.TCP/IP协议栈和应用程序以分离的任务运行 2.应用同协议栈沟通是通过API函数调用(API函数调用事实上就是通过OS自带的进程间通信机制,由应用程序 ...