CF-805B
B. 3-palindrometime limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard 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.
InputThe first line contains single integer n (1 ≤ n ≤ 2·105) — the length of the string.
OutputPrint the string that satisfies all the constraints.
If there are multiple answers, print any of them.
Examplesinput2outputaainput3outputbbaNoteA 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的更多相关文章
- 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 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- cf Round 613
A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...
- ARC下OC对象和CF对象之间的桥接(bridge)
在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...
- [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现
1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...
- 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 ...
- 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 ...
- CF #376 (Div. 2) C. dfs
1.CF #376 (Div. 2) C. Socks dfs 2.题意:给袜子上色,使n天左右脚袜子都同样颜色. 3.总结:一开始用链表存图,一直TLE test 6 (1)如果需 ...
- CF #375 (Div. 2) D. bfs
1.CF #375 (Div. 2) D. Lakes in Berland 2.总结:麻烦的bfs,但其实很水.. 3.题意:n*m的陆地与水泽,水泽在边界表示连通海洋.最后要剩k个湖,总要填掉多 ...
- CF #374 (Div. 2) D. 贪心,优先队列或set
1.CF #374 (Div. 2) D. Maxim and Array 2.总结:按绝对值最小贪心下去即可 3.题意:对n个数进行+x或-x的k次操作,要使操作之后的n个数乘积最小. (1)优 ...
随机推荐
- Nouveau源代码分析(三):NVIDIA设备初始化之nouveau_drm_probe
Nouveau源代码分析(三) 向DRM注冊了Nouveau驱动之后,内核中的PCI模块就会扫描全部没有相应驱动的设备,然后和nouveau_drm_pci_table对比. 对于匹配的设备,PCI模 ...
- UVA10317- Equating Equations(回溯+剪枝)
题目链接 题意:给出一个式子,但这个式子不一定是等式,在'+','-','='符号位置不变的情况下,又一次排列数字的位置,使其成为等式.假设能够的话.输出当中一种排列方式. 思路:我们将等号右边的数所 ...
- Cadence SPB 16. 6 安装步骤
1.首先下载Cadence Allegro SPB orCAD16. 6 安装包,单击我,下载之后运行其中的setup.exe,然后先安装第一项License Manager
- Spring Cloud(十一):Spring Cloud Zuul网关 Filter、熔断、重试、高可用的使用方式
上篇文章主要介绍了Zuul网关使用模式,以及自动转发机制,但其实Zuul还有更多的应用场景,比如:鉴权.流量转发.请求统计等等,这些功能都可以使用Zuul来实现. Zuul的核心 Filter是Zuu ...
- 使用Auto Layout处理比例间距问题
使用Auto Layout处理比例间距问题 Auto Layout 是一个掌握起来很具有挑战性的东西.iOS 9引入的 Stack Views和 layout 锚点有一些帮助,但是明白如何创建特定的 ...
- 简述C++中的多态机制
前言 封装性,继承性,多态性是面向对象语言的三大特性.其中封装,继承好理解,而多态的概念让许多初学者感到困惑.本文将讲述C++中多态的概念以及多态的实现机制. 什么是多态? 多态就是多种形态,就是许多 ...
- web前端页面中异步使用百度地图API
<div id="allmap"></div> //百度地图API功能 function loadJScript() { var script = docu ...
- GitLab Pages expect to run on their own virtual host
GitLab Pages administration | GitLab https://docs.gitlab.com/ce/administration/pages/
- android打包签名,从生成keystore到完成签名
输入指令并获得结果:(对应自己的java安装目录) 首先,我们需要一个keystore,当然已经有了的话就不用这一步了:cmd下:进入到jdk的bin目录,这样的话,android.keystore文 ...
- Kafka 配置参数汇总及相关说明
Kafka为broker,producer和consumer提供了很多的配置参数. 了解并理解这些配置参数对于我们使用kafka是非常重要的.本文列出了一些重要的配置参数. 官方的文档 Configu ...