D. Arpa and a list of numbers Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017)
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)的更多相关文章
- 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 ...
- 【前缀和】【枚举倍数】 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 ...
- 【推导】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为上顶点.那么其外接圆圆心即 ...
- 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 ...
- 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, ...
- 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 ...
- 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 ...
- Codeforces Round #432 (Div. 1, based on IndiaHacks Final Round 2017) D. Tournament Construction(dp + 构造)
题意 一个竞赛图的度数集合是由该竞赛图中每个点的出度所构成的集合. 现给定一个 \(m\) 个元素的集合,第 \(i\) 个元素是 \(a_i\) .(此处集合已经去重) 判断其是否是一个竞赛图的度数 ...
- 【推导】【暴力】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个点,那么再往里面添加任意多个 ...
随机推荐
- Python序列之元组 (tuple)
作者博文地址:http://www.cnblogs.com/spiritman/ Python的元组与列表类似,同样可通过索引访问,支持异构,任意嵌套.不同之处在于元组的元素不能修改.元组使用小括号, ...
- vim 多个文件切换 :b 命令
MiniBufExplorer插件的使用 博客分类: vim vimMiniBufExplorer 快速浏览和操作Buffer -- 插件: MiniBufExplorer 下载地址 [http:// ...
- Buaaclubs的NABC与发布
NEED: 本项目主要目的是实现一个社团学生公共平台,平台的宗旨是为学生提供信息,为社团提供服务,在社团和学生之间建立联系.经过调查,我们发现了用户的以下需求: 需求一:社团发布信息,同学获知信息 这 ...
- struts2 中怎样获取HttpServletReqest
struts2 中怎样获取HttpServletRequest 和HttpServletResponse 提供两种方法 第一种通过调用ServletActionContext这个类源代码中提供这个对象 ...
- 灵悟礼品网上专卖店Sprint计划
一.现状 小组成员初步了解了所做项目的大致内容,需要时间一步一步分析和规划. 二.部分需求索引卡 第一个阶段没有具体功能的实现,只是先把所要做的项目思路理清,并把相应的数据库建立好. 三.任务认领 产 ...
- 2016011998+sw
Coding.net原码仓库地址:https://git.coding.net/laolaf/sw.git 目录 1 需求分析 2 功能设计 3 设计实现 4 算法详解 5 测试运行 6 满意代码 1 ...
- Linux操作系统(一)
操作系统:介于硬件与用户之间的一组程序,方便用户操作,用以管理计算机的所有活动及硬件资源. 1.硬件->内核->系统调用(shell.命令)->应用程序. 只要具备以下几点,即可称为 ...
- contos7忘记root密码怎么办
首先在这个界面按"e"键 然后呢就会进入到如下图所示的界面,在LANG=zh_CN.UTF8的后面加上 init=/bin/sh, 再按 [ Ctrl + X ] 进入'单用户模式 ...
- elicpse
摘自http://blog.csdn.net/bug_love/article/details/72636505 eclipse error pages打红X的解决方法 我每次建一个Maven项目转为 ...
- Beta版本发布140字评论
1.飞天小女警组: 礼物挑选工具:系统界面十分新颖,相比于前阶段,增加了账号登陆的功能,并且还根据不同的价位区间添加了礼物的图片,并根据礼物的受欢迎程度添加了top10的功能,并且增加了关于本网站的问 ...