读懂题意就是水题,按照出现次数对下标排一下序,暴力。。

#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(水)的更多相关文章

  1. codeforce Gym 100500H ICPC Quest (简单dp)

    题意:给一个nXm的矩阵,上面有一些数字,从左上角出发,每次只能往右或者往下,把沿途的数字加起来,求到达右下角的最大值是多少. 题解:简单的一个dp,设f[i][j]为到达i行j列的最大值,f[i][ ...

  2. codeforces Gym 100500C C. ICPC Giveaways 排序

    Problem C. ICPC GiveawaysTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/1005 ...

  3. codeforces Gym 100500H H. ICPC Quest 水题

    Problem H. ICPC QuestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/a ...

  4. codeforce Gym 100500I Hall of Fame (水)

    题意:统计一些串中,字母的出现频率,不分大小写,找出现频率最高5个字符(相同频率优先取字典序大的),把他们的对应的值加起来判断以下是否大于62. 没出现的不算. #include<cstdio& ...

  5. Codeforces gym 100685 C. Cinderella 水题

    C. CinderellaTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/C ...

  6. Codeforce Gym 100015I Identity Checker 暴力

    Identity Checker 题目连接: http://codeforces.com/gym/100015/attachments Description You likely have seen ...

  7. codeforces Gym 100500C D.Hall of Fame 排序

    Hall of Fame Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/attachmen ...

  8. Codeforces GYM 100114 B. Island 水题

    B. Island Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description O ...

  9. Codeforces Gym 100286G Giant Screen 水题

    Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...

随机推荐

  1. NSMutableAttributedString及NSMutableParagraphStyle的使用

    一.在iOS开发中,常常会有一段文字显示不同的颜色和字体,或者给某几个文字加删除线或下划线的需求.之前在网上找了一些资料,有的是重绘UILabel的textLayer,有的是用html5实现的,都比较 ...

  2. Working Experience - WPF 中 DataGrid 控件的应用

    问题: 添加控件后, 编辑单元格会出现异常 绑定 ItemsSource 属性后, 更新绑定对象的数据, UI 不刷新 如何显示控件中 ComboBox 类型 解决方法: 绑定 ItemsSource ...

  3. tcpkill工作原理分析

    此文已由作者张耕源授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 日常工作生活中大家在维护自己的服务器.VPS有时会碰到这样的情况:服务器上突然出现了许多来自未知ip的网络连 ...

  4. Automake使用(初级)

    工程地址 https://github.com/silvermagic/automakeDev.git 最初工程目录结构 $ vim main.cpp $ vim src/main.cpp ls -l ...

  5. 关于define

    <?php define('local','localhost');//echo constant('local');exit(); define('username','root'); def ...

  6. unity update优化

    http://forum.china.unity3d.com/thread-13968-1-1.html Unity有个消息系统,它可以在运行中当发生指定事件时调用你在脚本中定义的那些魔术方法.这是个 ...

  7. jzoj6002. 【PKUWC2019模拟2019.1.15】Permutation (组合数)

    题面 题解 设\(lim=(n-1)/2\)(这里是下取整),那么\(x\)位置的值最大不能超过\(lim\),而\(y\)处的值不能小于\(y\),于是有\[Ans=\sum_{i=1}^{lim} ...

  8. js 阻止元素发生默认的行为ie兼容

    //亲测ie9可以兼容 function Go(event) { var e = event; if (e && e.preventDefault) { e.preventDefaul ...

  9. Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) D

    Arpa has found a list containing n numbers. He calls a list bad if and only if it is not empty and g ...

  10. TPU的相关资料

    1.谷歌 TPU 的强大与局限:TPU/GPU/CPU性能功耗全面对比:http://www.sohu.com/a/134315786_473283 2.谷歌发布TPU论文,75位联合作者,GPU迎来 ...