code forces 805B (水)

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#define LL long long

using namespace std;

//就是给你一个字符串长度,然后要求不能出现长度为3的回文子串。使用c尽可能少。

char str[200005];

int main()
{
int n,op1=0,op2=0;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
if(i==0)
{
str[i]='a';
op1++;
}

else if(op1==1)
{
str[i]='a';
op1++;
}

else if(op2==1)
{
str[i]='b';
op2++;
}

else if(op1==2)
{
str[i]='b';
op2++;
op1=0;
}

else if(op2==2)
{
str[i]='a';
op1++;
op2=0;
}
}
str[n]=' ';
printf("%s",str);
return 0;
}

原文地址:https://www.cnblogs.com/alan-W/p/6824613.html