codeforce Gym 100500C ICPC Giveaways(水)
读懂题意就是水题,按照出现次数对下标排一下序,暴力。。
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll; const int maxn = 1e4+;
ll cnt[maxn];
ll r[maxn];
bool cmp(int a,int b) { return cnt[a] > cnt[b]; } int main()
{
int T;
scanf("%d",&T);
for(int k = ; k <= T; k++){
int M,N,C;
scanf("%d%d%d",&M,&N,&C);
memset(cnt,,sizeof(cnt));
for(int i = ; i < M; i++){
int tmp;
scanf("%d",&tmp);
cnt[tmp]++;
}
for(int i = ; i < N; i++) { r[i] = i+; }
sort(r,r+N,cmp);
ll amus = (r[]*r[])%C;
ll best = cnt[r[]]*amus;
for(int i = ; i < N; i++) {
amus += (r[i]*r[i])%C;
ll tmp = cnt[r[i]]*amus;
best = max(best,tmp);
}
printf("Case %d: %I64d\n",k,best);
}
return ;
}
codeforce Gym 100500C ICPC Giveaways(水)的更多相关文章
- codeforce Gym 100500H ICPC Quest (简单dp)
题意:给一个nXm的矩阵,上面有一些数字,从左上角出发,每次只能往右或者往下,把沿途的数字加起来,求到达右下角的最大值是多少. 题解:简单的一个dp,设f[i][j]为到达i行j列的最大值,f[i][ ...
- codeforces Gym 100500C C. ICPC Giveaways 排序
Problem C. ICPC GiveawaysTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/1005 ...
- codeforces Gym 100500H H. ICPC Quest 水题
Problem H. ICPC QuestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/a ...
- codeforce Gym 100500I Hall of Fame (水)
题意:统计一些串中,字母的出现频率,不分大小写,找出现频率最高5个字符(相同频率优先取字典序大的),把他们的对应的值加起来判断以下是否大于62. 没出现的不算. #include<cstdio& ...
- Codeforces gym 100685 C. Cinderella 水题
C. CinderellaTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/C ...
- Codeforce Gym 100015I Identity Checker 暴力
Identity Checker 题目连接: http://codeforces.com/gym/100015/attachments Description You likely have seen ...
- codeforces Gym 100500C D.Hall of Fame 排序
Hall of Fame Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/attachmen ...
- Codeforces GYM 100114 B. Island 水题
B. Island Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description O ...
- Codeforces Gym 100286G Giant Screen 水题
Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...
随机推荐
- android fragment ontouch 事件
由于fragment是存在于activity之中的,所以触摸事件会被activity首先得到. 为了在fragment中执行ontouch方法,需要做如下处理: mFragment = new Tab ...
- ASP.NET学习笔记(四)CDOSYS邮件
使用 CDOSYS 发送电子邮件 CDO (Collaboration Data Objects) 是一项微软的技术,设计目的是用来简化通信程序的创建. CDOSYS 是 ASP 中的内置组件.我们会 ...
- laravel ajax提交登陆存储session,并输出
前端输出session {{ Session::get('username') }} ajax提交 <div>{{ Session::get('username') }}</div& ...
- 【转】mysql中set autocommit=0与start transaction的关系
在mysql中用户的任何一个更新操作(写操作)都被视为一个事务,set autocommit=0指事务非自动提交,自此句执行以后,每个SQL语句或者语句块所在的事务都需要显示"commit& ...
- codevs 1086 栈(Catalan数)
题目描述 Description 栈是计算机中经典的数据结构,简单的说,栈就是限制在一端进行插入删除操作的线性表. 栈有两种最重要的操作,即pop(从栈顶弹出一个元素)和push(将一个元素进栈). ...
- CentOS6.7 i686上安装JDK7
内核版本: [root@heima01 java]# uname -a Linux heima01 2.6.32-573.el6.i686 #1 SMP Thu Jul 23 12:37:35 UTC ...
- IOS字符串截取保留小数点后两位
-(NSString*)getTheCorrectNum:(NSString*)tempString { //计算截取的长度 NSUInteger endLength = tempString.len ...
- js 去除字符串空白符
var a=" 123456" varb=a.replace(/(^\s*)/g, "");
- Linux修改war包中文件
rm -rf /tmp/wiq.warcp /u02/wms_dev/wiq-app/wars/wiq.war /tmpcd /tmp jar xvf wiq.war vim WEB-INF/clas ...
- ASP.NET Core 2.0 源代码
ASP.NET Core 2.0 源代码 在Visual Studio 2017中可以通过符号以及源链接,非常方便对 ASP.NET Core 2.0中源代码进行调试.在这篇文章中,我们将重点介绍如何 ...