14.笨小猴
2022-12-19 12:04:05
发布于:江苏
454阅读
0回复
0点赞
14.[NOIP2008 提高组] 笨小猴
难度:普及/提高-
来源:--
AC代码(C++):
#include <bits/stdc++.h>
/*
#include <iostream>
#include <cctype>
#include <string.h>
#include <algorithm>
*/
using namespace std;
string s1;
int maxn = -114514,minn = 2147483646,l1;
int nlp[26];
int lucky,zs,cnt;
string alp = "abcdefghijklmnopqrstuvwxyz"; // 26个字母
string sa = "Lucky Word";
string ** = "No Answer"; // 答案错误
int i,j;
int print(int x)
{
for (i = 1; i <= x; i++)
{
if (x % i == 0)
{
zs++;
}
}
return zs;
}
int main(void)
{
cin >> s1; // getline(cin,s1);
l1 = s1.size();
for (i = 0; i < l1; i++)
{
for (j = 0; j < 26; j++)
{
if (s1[i] == alp[j])
{
nlp[j]++;
}
}
}
for (i = 0; i < 26; i++)
{
if (nlp[i] <= minn and nlp[i] != 0)
{
minn = nlp[i];
}
if (nlp[i] >= maxn)
{
maxn=nlp[i];
}
}
// cout << nlp[0]; // 检验
lucky = maxn - minn;
print(lucky);
if (zs == 2)
{
cout << sa << endl << lucky;
}
else
{
cout << ** << endl << 0;
}
return 0;
}
没有注释,自行学习。 注释有了,自行食用
by:yanghaozhe
你的点赞和关注就是我更新题解的最大动力!
-----------------------------点个赞吧 ↓ !-----------------------------
全部评论 1
题目中的**是指变量“s b”
2022-12-29 来自 江苏
3你挺幽默的
2023-07-15 来自 广东
0六百六十六,盐都不盐了
2025-02-09 来自 山东
0
有帮助,赞一个