51Nod-1182-完美字符串
来源:互联网 发布:java ee api下载 编辑:程序博客网 时间:2024/05/17 07:19
ACM模版
描述
题解
先进行大小写转换并统计各字母出现次数,然后排序,最后按出现次数的顺序分配权值,出现次数越多,权值越大,累加即可。
代码
#include <iostream>#include <cstdio>#include <string>#include <algorithm>using namespace std;string S;int letter[100] = {0};int main(int argc, const char * argv[]){ while (cin >> S) { for (int i = 0; i < S.length(); i++) { if (S[i] > 90) { S[i] -= 32; } letter[S[i]]++; } sort(letter + 65, letter + 91); int val = 26; int ans = 0; for (int i = 90; i >= 65; i--) { ans += letter[i] * val--; } printf("%d\n", ans); } return 0;}
0 0
- 51Nod-1182-完美字符串
- 51NOD 1182 完美字符串
- 51nod 1182 完美字符串
- 51 nod 1182 完美字符串
- 51nod 1182 完美字符串
- 51nod 1182完美字符串
- 51nod 1182 完美字符串
- 51Nod 1182 完美字符串
- 【51Nod】1182 完美字符串
- 51nod 1182 完美字符串
- 51Nod 1182 完美字符串
- 51nod 1182 完美字符串
- 51nod-完美字符串
- 51nod 完美字符串
- 51 Nod 完美字符串
- 【51Nod】1182 - 完美字符串(贪心)
- 51nod 1182 完美字符串【贪心】
- 51nod 1182 完美字符串(贪心)
- BZOJ2002-弹飞绵羊 LCT
- TCP/IP模型的各层的作用
- 范式的理解
- 链表例题
- pthread取消选项
- 51Nod-1182-完美字符串
- linux SSH 远程登陆环境搭建
- Android 中使用极光推送消息详细介绍(一)
- 树 的例题
- 关于在外部拿到RecyclerView的viewholder的几种方式
- android gridview布局添加多个title
- Your local changes to the following files would be overwritten by merge: git
- Mybatis中通过HaseMap封装参数作为查询条件
- Spring框架详解