http://codeforces.com/contest/851/problem/D

分区间操作

 #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <time.h>
#include <string>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <ext/rope>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long
#define minv 1e-6
#define inf 1e18
#define pi 3.1415926536
#define E 2.7182818284
const ll mod=1e9+;//
const int maxn=2e6+; bool vis[maxn]={};
ll tot[maxn]={},sum[maxn]={}; int main()
{
int n,x,y,z,i,j,pos;
ll v,r=inf,a;
scanf("%d%d%d",&n,&x,&y);
z=x/y;
for (i=;i<=n;i++)
{
scanf("%lld",&a);
tot[a]++;
sum[a]+=a;
}
for (i=;i<=2e6;i++)
tot[i]+=tot[i-],sum[i]+=sum[i-];
for (i=;i<=1e6;i++)
if (!vis[i])
{
v=;
//(j-i,j)
for (j=i;j<=2e6;j+=i)
{
pos=max(j-z,j-i+);//[pos,j]
v+= (ll)(tot[pos-]-tot[j-i])*x + ( (ll)(tot[j]-tot[pos-])*j-(ll)(sum[j]-sum[pos-]) )*y;
vis[j]=;
}
r=min(r,v);
}
cout<<r;
return ;
}

D. Arpa and a list of numbers Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017)的更多相关文章

  1. Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017)ABCD

    A. Arpa and a research in Mexican wave time limit per test 1 second memory limit per test 256 megaby ...

  2. 【前缀和】【枚举倍数】 Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) D. Arpa and a list of numbers

    题意:给你n个数,一次操作可以选一个数delete,代价为x:或者选一个数+1,代价y.你可以进行这两种操作任意次,让你在最小的代价下,使得所有数的GCD不为1(如果全删光也视作合法). 我们从1到m ...

  3. 【推导】Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) B. Arpa and an exam about geometry

    题意:给你平面上3个不同的点A,B,C,问你能否通过找到一个旋转中心,使得平面绕该点旋转任意角度后,A到原先B的位置,B到原先C的位置. 只要A,B,C构成等腰三角形,且B为上顶点.那么其外接圆圆心即 ...

  4. 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 ...

  5. Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) B

    Arpa is taking a geometry exam. Here is the last problem of the exam. You are given three points a,  ...

  6. Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) A

    Arpa is researching the Mexican wave. There are n spectators in the stadium, labeled from 1 to n. Th ...

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

    昨晚打得小号,虽然很菜,可是还是涨了些rating A. Arpa and a research in Mexican wave time limit per test 1 second memory ...

  8. Codeforces Round #432 (Div. 1, based on IndiaHacks Final Round 2017) D. Tournament Construction(dp + 构造)

    题意 一个竞赛图的度数集合是由该竞赛图中每个点的出度所构成的集合. 现给定一个 \(m\) 个元素的集合,第 \(i\) 个元素是 \(a_i\) .(此处集合已经去重) 判断其是否是一个竞赛图的度数 ...

  9. 【推导】【暴力】Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) C. Five Dimensional Points

    题意:给你五维空间内n个点,问你有多少个点不是坏点. 坏点定义:如果对于某个点A,存在点B,C,使得角BAC为锐角,那么A是坏点. 结论:如果n维空间内已经存在2*n+1个点,那么再往里面添加任意多个 ...

随机推荐

  1. zookeeper_节点数据版本号问题

    转自:Simba_cheng 更新节点数据的方法: 同步方法:Stat setData(final String path, byte data[], int version) 异步方法:void s ...

  2. ubuntu16.04 CUDA, CUDNN 安装

    这次介绍的是使用 tensorflow1.8, cuda9.0, cudnn7.0的版本 https://developer.nvidia.com/cuda-90-download-archive 下 ...

  3. Windows下 搭建redis集群

    Windows下搭建redis集群教程 一,redis集群介绍 Redis cluster(redis集群)是在版本3.0后才支持的架构,和其他集群一样,都是为了解决单台服务器不够用的情况,也防止了主 ...

  4. QT中的小细节

    一 .  QT4和QT5的区别(信号和槽):1.  QT4: connect(button,SIGNAL(pressed()),this,SLOT(close())); /** * 优点 :写法简单 ...

  5. Metasploit拿Shell

    进入metasploit系统 msfconsole Nmap端口扫描 nmap –sV IP(或者域名),如果机器设置有防火墙禁ping,可以使用nmap -P0(或者-Pn) –sV IP(或者域名 ...

  6. 前端_JavaScript

    目录 JavaScript的基础 引入方式 JS的变量.常量和标识符 JS的数据类型 运算符 流程控制 JavaScript的对象 String对象 Array对象 Date对象 Math对象 Fun ...

  7. Scrum Meeting 11.11

    成员 今日任务 明日计划 用时 徐越 学习UI设计并重构上传下载界面     赵庶宏       薄霖 UI代码更新     卞忠昊 Xfermode与PorterDuff     武鑫 界面设计:独 ...

  8. Chapter 2 软件过程

    软件发展前期,人们只重视结果而忽略了过程,随着技术的成熟,软件过程的重要性被日益发觉.软件过程是软件工程人员为了获得软件产品而在软件工具的支持下实施的一系列软件工程活动. 软件过程的基本活动包括问题提 ...

  9. 浅谈GIT

    浅谈GIT: 牛老师提出的git,于我而言,是一个陌生和新鲜的词汇,在此之前我从未听过git,按照老师的要求,我去搜索了关于git的介绍,有些看懂了,但大部分还是不懂得,在介绍中我了解git其实之前使 ...

  10. wamp 修改www目录

    我的情况 Wamp版本:2.2 WAMP2.2安装目录:C:/ www目录:D:/wamp/www/ 变更目录:E:/HbuilderProjects/ 一 主要过程: (1)修改 D:\wamp\b ...