# Codeforces 979B

##### 题目链接

https://vjudge.net/problem/CodeForces-979B

##### 思路

• 如果mx==len且n==1，即aaa这种情况，只能变成aab，所以ans=mx-1
• 否则，如果mx+n比原字符串长度还大，就是字符串长度，即ans=min(n+mx, len)

n=1这种情况比较容易难想到，还很容易想成n为奇数，这是不对的。

##### AC代码
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<string>
#include<sstream>
#include<cctype>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<cstdlib>
#include<ctime>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1000000007;

const int maxn = 100010;
char s[maxn];
int a[52];
int n, len;

{
scanf("%s", s);
len = strlen(s);
memset(a, 0, sizeof(a));
for(int i = 0; i < len; i++)
{
if(s[i] >= 'a' && s[i] <= 'z')
a[s[i] - 'a']++;
else
a[s[i] - 'A' + 26]++;
}
int mx = 0;
for(int i = 0; i < 52; i++)
{
if(a[i] > mx)
mx = a[i];
}
if(mx == len && n == 1)
mx = mx - 1;
else
mx = min(len, mx + n);
return mx;
}

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
int x, y, z;
scanf("%d", &n);

int ans[3] = {x, y, z};
sort(ans, ans + 3);
if(ans[2] == ans[1])
{
printf("Draw\n");
}
else
{
if(ans[2] == x)
printf("Kuro\n");
else if(ans[2] == y)
printf("Shiro\n");
else
printf("Katie\n");
}
return 0;
}

• 广告
• 抄袭
• 版权
• 政治
• 色情
• 无意义
• 其他

120