A. Polycarp's Pockets

题目链接:codeforces 1003A

题意:

     给n个数,要求相同的数不能放在一个口袋,问最少需要多少个口袋

题解:

    求出最多的相同数的个数,就是答案

#include<cstdio>
#include<cstring>
int main(){int n;int a[105];memset(a,0,sizeof(a));scanf("%d",&n);for(int i = 1;i <= n;i++){int x;scanf("%d",&x);a[x]++;}int max = -100;for(int i = 1;i <= 100;i++){if(max < a[i]){max = a[i];}}printf("%d\n",max);return 0;
}

C. Intense Heat(暴力)

题目链接:codeforces 1003C

题意:

   给出 n 个值,求 大于等于 k 个数的最大平均值

题解:

   先求前缀和,然后暴力

AC代码

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){ll a[5005], u;int n, k;cin >> n >> k;memset(a, 0, sizeof(a));for(int i = 1; i <= n; i++){cin >> u;a[i] = a[i-1] + u;}a[0] = 0;double maxx = 0.0;for(int i = 1; i <= n; i++){for(int j = i+k-1; j <= n; j++){double k = (double)(a[j] - a[i-1]);double p = (double) (j - i + 1);if(k / p * 1.0 > maxx){maxx = k / p * 1.0;}}}printf("%.12lf\n", maxx);return 0;
}

codeforces 1003A. Polycarp's Pockets,C. Intense Heat(暴力)相关推荐

  1. CodeForces - 1003A Polycarp's Pockets

    题目链接: A. Polycarp's Pockets time limit per test 1 second memory limit per test 256 megabytes input s ...

  2. codeforces 1003a Polycarp's Pockets

    http://www.elijahqi.win/archives/3910 求出现次数最多的数出现几次 #include<bits/stdc++.h> using namespace st ...

  3. codeforces 解题报告 1003A. Polycarp's Pockets 模拟

    http://codeforces.com/problemset/problem/1003/A 解题思路: 1.每个包里只能有不同面额的硬币,问要多少个包才能装完这堆硬币 2.弄n个桶,桶内是相同硬币 ...

  4. Codeforces #494 A. Polycarp's Pockets

    A. Polycarp's Pockets 废话不多说,直接上AC程序! #include<bits/stdc++.h> using namespace std; int n,x; int ...

  5. Codeforces 1005D Polycarp and Div 3

    Codeforces 1005D Polycarp and Div 3 dp[i]表示前i个数最多能分成多少块%3为0,nxt[x]表示x这个上一次出现的位置. 首先想到 $ dp[i] = max( ...

  6. 落谷CF1003A Polycarp's Pockets

    题目描述 Polycarp has n n n coins, the value of the i i i -th coin is ai a_i ai​ . Polycarp wants to dis ...

  7. CodeForces 858C Did you mean... 、 CodeForces 858D Polycarp's phone book!黑科技

    C. Did you mean... 题意:将一个字符串最少分成几个小的字符串,使得每个字符串都没有连续三个及以上的辅音字母,连续三个相同的辅音字母不算. 贪心构造即可,注意连续三个相同的辅音的时候将 ...

  8. Codeforces 861D - Polycarp's phone book 字典树/hash

    输入7e4个字符串,要求每个串提取一个子串来唯一表示 4s题可以hash暴力水过,大体思路就是把所有子串map自己的母串,过程中如果这个子串已有hash值就标-1 然后枚举map元素,维护最小化一下就 ...

  9. CodeForces - 858D Polycarp's phone book(字典树/map)

    题目链接:点击查看 题目大意:给出n个电话号码,每个电话号码都由9位数字组成,我们需要输出每个电话号码的最小关键词,最小关键词是指当输入这个关键词后,只能与当前的电话号码的其中一段匹配,而不能和其他电 ...

最新文章

  1. 2022-2028年中国小球产业深度调研及投资前景预测报告(全卷)
  2. 【Android】AsyncTask异步类
  3. PHP访问mysql的常用函数,PHP操作MySQL数据库常用函数
  4. 应用MaxCompute实现变压器局部放电相位分析
  5. java 白皮书_java第三天学习内容回顾——java白皮书第四章
  6. Node版本管理nvm, npm
  7. 数据库之Oracle 查询 select - day01
  8. java 解决汉诺塔问题
  9. stl取出字符串中的字符_从C ++ STL中的字符串访问字符元素
  10. Taro+react开发(70):flex布局
  11. 【玩转MLS系列】基础教程
  12. 2021年本溪高中高考成绩查询入口,2021年本溪中考录取结果查询,什么时候出来附查询网址入口...
  13. 根据输入数字显示对应的英文星期名称缩写
  14. 医学报告生成论文总结【4-24】
  15. uniapp开发的H5网页,以表单形式调起微信H5支付
  16. MIT周博磊:CV本质上是一门科学研究
  17. 认真分享几个「副业赚钱」的靠谱思路!
  18. find -perm 里的 + -的含义
  19. SPIN Routing Algorithm
  20. 北京工业计算机英语口语复试,北京工业大学复试回忆

热门文章

  1. Django路由配置-快速上手
  2. 性能测试这些常用工具你一定要知道!【建议收藏!】
  3. c语言 结构类型(详细)
  4. 英国商业经济金融发展史
  5. 基于 dpdk-nginx 的 c1000k 并发研发
  6. javascript 月份日期 取两位保留
  7. windows更新node版本
  8. Microsoft JET Database Engine 错误 '80004005' 不可识别的数据库格式
  9. GWAS分析新软件 | GMATs:解析复杂性状和复杂遗传机制的高效工具
  10. 百万在线,你们能接得住吗?