题解
2024-05-28 13:04:51
发布于:广东
18阅读
0回复
0点赞
认真审题,我们可以发现,只是单单一个B就能增长成个B!
所以,我们只需要判断前n个数是否全是A就行了
#include <iostream>
#include <cstdio>
using namespace std;
string a;
int n;
int main(){
cin >> a >> n;
int i;
for(i = 0; a[i] != '\0' && a[i] == 'A'; i++);//统计前面A的个数
if(i > n) cout << 'A';//如果前N个数都是A输出A
else cout << a[i];//否则输出第一个不是A的数
return 0;
}
时间复杂度:
这里空空如也
有帮助,赞一个