[Codeforces 731 F. Video Cards](http://codeforces.com/problemset/problem/731/F)
题目大意:给一组数,从中选一个数作lead,要求其他所有数减少为其倍数,再求和。问所求和的最大值。
思路:统计每个数字出现的个数,再做前缀和,用于之后快速求和。将原数组排序后去重,枚举每一个数做lead的情况下,其余数减少后再求和的结果。不断维护最大值即可。
PS:这里用到了一个方便的函数unique()来去重,使用前需要先将数组排序,参数为数组的首地址和尾后地址,返回新的尾后地址。(该函数没有将重复的元素删除,只是放到了尾地址后面)可以用len=unique(a,a+n)-a得到去重后数组的长度。
附上代码:
```C++
#include
#include
#include
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
int a[maxn];
int cnt[maxn*2+5];
int main()
{
int n,i,j;
cin>>n;
for (i=0;i

Codeforces 731 F. Video Cards(前缀和)的更多相关文章

  1. Codeforces Round #376 (Div. 2) F. Video Cards —— 前缀和 & 后缀和

    题目链接:http://codeforces.com/contest/731/problem/F F. Video Cards time limit per test 1 second memory ...

  2. Codeforces Round #376 (Div. 2) F. Video Cards 数学,前缀和

    F. Video Cards time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  3. 【19.05%】【codeforces 731F】 Video Cards

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. Codeforces Round #376 (Div. 2)F. Video Cards(前缀和)

    题目链接:http://codeforces.com/contest/731/problem/F 题意:有n个数,从里面选出来一个作为第一个,然后剩下的数要满足是这个数的倍数,如果不是,只能减小为他的 ...

  5. Codeforces Round #376 (Div. 2) F. Video Cards 数学 & 暴力

    http://codeforces.com/contest/731/problem/F 注意到一个事实,如果你要找一段区间中(从小到大的),有多少个数是能整除左端点L的,就是[L, R]这样.那么,很 ...

  6. Video Cards

    Video Cards time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...

  7. Codeforces 959 F. Mahmoud and Ehab and yet another xor task

    \(>Codeforces\space959 F. Mahmoud\ and\ Ehab\ and\ yet\ another\ xor\ task<\) 题目大意 : 给出一个长度为 \ ...

  8. Codeforces 835 F. Roads in the Kingdom

    \(>Codeforces\space835 F. Roads in the Kingdom<\) 题目大意 : 给你一棵 \(n\) 个点构成的树基环树,你需要删掉一条环边,使其变成一颗 ...

  9. Codeforces Round #552 (Div. 3) F. Shovels Shop (前缀和预处理+贪心+dp)

    题目:http://codeforces.com/contest/1154/problem/F 题意:给你n个商品,然后还有m个特价活动,你买满x件就把你当前的x件中最便宜的y件价格免费,问你买k件花 ...

随机推荐

  1. cef chromium 编译

    前言 目前客户端引用了cef sharp库来嵌入web页面 cef sharp是对cef (chromium embed framework)的c#封装 cef是对chromium内核的c++封装 什 ...

  2. 后端查询树的通用SQL,具备懒加载功能

    select t.org_id as key, --key值 t.org_name as title, --标题 t.has_sub as folder, --是否显示文件夹 t.has_sub as ...

  3. vue导航栏制作

    1,在components新建commnn目录,然后再新建nav目录,在此目录下新建nav-bottom.vue文件和nav-item.vue文件 2,nav-bottom.vue中的内容: < ...

  4. HTML的学习2(注释)

    <!--链接标签--> <!--核心属性就是href 属性值可以是一个跳转的地址--> <a href="">可点击的文本</a> ...

  5. 1 c#传递表变量去存储数据的例子

    1 c# 代码 using (SqlConnection con = GetEditorConnection()) { con.Open(); using (SqlCommand command = ...

  6. java_day05_类和对象

    chap05目标:类和对象---------------------------------------------- 1.OOP特征概述 Java的编程语言是面向对象的,采用这种语言进行编程称为面向 ...

  7. Active Directory participation features and security extensions

    Participation in the Active Directory Samba 3.0 series, as well as the OS since Windows 2000, is pos ...

  8. itertools:处理可迭代对象的模块

    合并和分解迭代器 chain chain可以接收多个可迭代对象(或者迭代器)作为参数,最后返回一个迭代器. 它会生成所有输入迭代器的内容,就好像这些内容来自一个迭代器一样. 类似于collection ...

  9. Linux安装apidoc

    一.安装apidoc所需环境(nodejs) 1. 查看系统是32位还是64位 uname -r 可以看出我这台linux的是64位的 2. 到node官网下载node的包并上传linux https ...

  10. Java程序向MySql数据库中插入的中文数据变成了问号

    找到mysql的安装目录,修改my.ini文件 (1)如何找到my.ini文件 如果my.ini文件不在MySQL的安装目录下,可能放在隐藏目录,要先去找到ProgramData,(这里要先打开显示隐 ...