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 ...
随机推荐
- socket函数的使用方法(参数详解)
socket函数的使用方法如下: int socket(int domain, int type, int protocol); 在参数表中,domain指定使用何种的地址类型,比较常用的有: PF_ ...
- 交互原型设计软件axure rp学习之路(一)
开始学习之前,请一定要明白:Axure是个极其极其极其简单的软件.因为你所做的就是拖部件,打字,拖部件,打字,最多加个对齐.如果你能把axure当作word或者ppt来用,那你就学会了axure. A ...
- MS SQL读取JSON数据
前面有一篇<在SQL中直接把查询结果转换为JSON数据>https://www.cnblogs.com/insus/p/10905566.html,是把table转换为json. 现反过来 ...
- TCP/IP之大明邮差
大明王朝天启四年, 清晨. 天色刚蒙蒙亮,我就赶着装满货物的马车来到了南城门, 这里是集中处理货物的地方 , 一队一队的马车都来到这里, 城头的士兵带着头盔,身披盔甲, 手持长枪, 虎视眈眈的注视这下 ...
- linux命令之ll按时间和大小排序显示
ll不是命令,是ls -l的别名 按大小排序 [root@localhost ~]# ll -Sh 按时间排序 [root@localhost ~]# ll -rt ll -t 是降序, ll -t ...
- 简述RadioGroup和RadioButton的使用
简述RadioGroup和RadioButton的使用 在项目中有身份选择的选项,需要用到RadioGroup和RadioButton,这里做个记录,和大家交流一下. 话不多说,一起看代码 XML代码 ...
- Redis和springboot 整合redisUtil类
一.引入依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId> ...
- Invalid YGDirection 'vertical'. should be one of: ( inherit, ltr, rtl )
react native 路由( react-native-router-flux )跳转页面一直都报错 本项目解决方法:不是路由的问题,是跳转的页面有有问题,删除下图标记的红色即可(解决方法是排除法 ...
- Codeforces 140E(排列组合、dp)
要点 主要学到的东西:一个序列染色,相邻不染同色,恰用\(j\)种颜色的1.模式数.2.方案数.3.具体染色数. 从大的思路上来讲:先dp预处理出每一层的模式数:\(f[i][j]\)表示\(i\)个 ...
- Codeforces 140F(坐标系点对称)
要点 结论:如果坐标系一堆点两两对称于某一重心,则排序后第1个和第n个为一对,以此类推. 枚举所有可能的重心点并check.因为隐藏的点不超过k个,所以点1-k+1都可能跟第n个匹配.对右侧同样适用, ...