B. Appleman and Card Game
来源:互联网 发布:kali mysql暴力破解 编辑:程序博客网 时间:2024/05/22 00:06
Problem Link :http://codeforces.com/problemset/problem/462/B
code:
#include<iostream>
#include<algorithm>
using namespace std;
char s[111111];
__int64 p,n,k,i,m[27];
int main()
{
int flag;
while(scanf("%d%d",&n,&k)!=EOF)
{
scanf("%s",s);
memset(m,0,sizeof(m));
for(i=0;i<n;i++)
m[s[i]-'A']++;
sort(m,m+26);
flag=1;
p=0;
while(flag)
{
for(i=25;i>=0;i--)
{
k-=m[i];
if(k<=0)
{
p+=((k+m[i])*(k+m[i]));
flag=0;
break;
}
else
{
p+=(m[i]*m[i]);
}
}
}
printf("%I64d\n",p);
}
return 0;
}
0 0
- B. Appleman and Card Game
- B. Appleman and Card Game
- 462B - Appleman and Card Game
- CF 462B Appleman and Card Game
- 【CODEFORCES】 B. Appleman and Card Game
- Codeforces Round #263 (Div. 2)B. Appleman and Card Game
- Codeforces Round #263 (Div. 2)B. Appleman and Card Game
- Codefores Round #263 (div2) B. Appleman and Card Game
- codeforces 462 B.Appleman and Card Game (贪心)
- Codeforces 462B Appleman and Card Game(贪心)
- Codeforces Round #263 (Div. 2)-B. Appleman and Card Game
- CodeForces 462B Appleman and Card Game(贪心)
- CodeForces 462B Appleman and Card Game 贪心
- Code Forces 462B Appleman and Card Game
- Appleman and Card Game CodeForces
- Appleman and Card Game(贪心)
- 看看有什么问题CF 462B. Appleman and Card Game
- 【Codeforces Round 263 (Div 2)B】【水题 贪心】Appleman and Card Game 选字符,每个字符个数的平方
- mysql 存储过程错误调试记录
- 【重读设计模式】工厂方法模式
- Servlet/Jsp实现发送压缩Web页面 Gzip技术
- ios学习之 关于Certificate、Provisioning Profile、App ID的介绍及其之间的关系
- MAC配置SVN服务器
- B. Appleman and Card Game
- LRU算法,最近最少使用算法
- 全文搜素引擎
- 开始学Android啦
- 【关键字】【标识符】【常量】【变量】【进制转换】【运算符】
- hadoop - linux环境
- Oracle字符串连接的方法
- Mac环境下svn的使用完整版
- 成佩涛-mysql状态分析(性能优化)