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. 实验三:敏捷开发与XP实践

    Java实验三报告 一.   实验内容 (一)敏捷开发与XP 内容:1.敏捷开发(Agile Development)是一种以人为核心.迭代.循序渐进的开发方法. 2.极限编程(eXtreme Pro ...

  2. 2018-2019-20172321 《Java软件结构与数据结构》第八周学习总结

    2018-2019-20172321 <Java软件结构与数据结构>第八周学习总结 教材学习内容总结 第12章 优先队列与堆 一.概述 堆 堆的前提就是他首先是一个完全二叉树,其次就是满足 ...

  3. 再学HTML之一

    Html 超文本标记语言 什么是html? HTML 是用来描述网页的一种语言. HTML 指的是超文本标记语言 (Hyper Text Markup Language) HTML 不是一种编程语言, ...

  4. The last time the sprint(最后一个冲刺)

    经过一两个月的努力,我们终于是做出来了一点东西,从一开始接触这个项目开始,从完全不知道怎么去入手到跌跌碰碰,再到现在可以拿出来一点东西给别人看,我觉得很开心,或许我的这个成品在别人眼中并不算是什么,但 ...

  5. DPDK L2fwd 源码阅读

    代码部分 /* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2016 Intel Corporation */ #include ...

  6. 个人作业4——alpha阶段个人总结(201521123003 董美凤)

    一.个人总结 在alpha 结束之后, 每位同学写一篇个人博客, 总结自己的alpha 过程: 请用自我评价表:http://www.cnblogs.com/xinz/p/3852177.html 有 ...

  7. APP分析----饿了么

    产品      饿了么 选择原因:有了外卖就可以轻松拥有一个不用出门也饿不着的爽歪歪周末. 第一部分 调研, 评测 下载软件并使用起来,描述最简单直观的个人第一次上手体验. 主界面: 第一次上手是大一 ...

  8. UDP与TCP笔记

    1.UDP UDP协议在工作时是建立在IP协议之上的,UDP从进程的缓冲区接收进程每一次产生的输出,对每次输出都生成一个UDP数据报,然后把生成的UDP数据报直接封装在IP数据报中进行传输,因此在传输 ...

  9. static作用(修饰函数、局部变量、全局变量)

    转自:http://www.cnblogs.com/stoneJin/archive/2011/09/21/2183313.html 在C语言中,static的字面意思很容易把我们导入歧途,其实它的作 ...

  10. 订制EditText光标

    订制EditText光标 设置背景android:background="@null" 设置光标样式:android:textCursorDrawable="@drawa ...