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个点,那么再往里面添加任意多个 ...
 
随机推荐
- BOM 头是什么,怎么除去
			
WINDOWS自带的记事本,在保存一个以 UTF-8 编码的文件时,会在文件开始的地方插入三个不可见的字符(0xEF 0xBB 0xBF,即BOM).它是一串隐藏的字符,用于让记事本等编辑器识别这个文 ...
 - Node.js开发入门—套接字(socket)编程
			
Node.js的net模块提供了socket编程接口,方便我们利用较为底层的套接字接口来实现应用协议.这次我们看一个简单的回显服务器示例,包括服务端和客户端的代码. 代码 分服务器和客户端两部分来说吧 ...
 - Spring Bean注册解析(二)
			
在上文Spring Bean注册解析(一)中,我们讲解了Spring在注册Bean之前进行了哪些前期工作,以及Spring是如何存储注册的Bean的,并且详细介绍了Spring是如何解析 ...
 - HTML常用头部变量
			
简例:访问baidu的头部 GET /?tn=98827400_hao_pg HTTP/1.1 Host: www.baidu.com Connection: keep-alive Cache-Con ...
 - reduce()用法
			
reduce()方法接受一个函数作为累加器,数组中的每个值(从左到右)开始缩减,最终为一个值 参数 callback 执行数组中的每个值的函数,包含四个参数 previousValue 上一次调用回调 ...
 - Spring的Controller映射规则
			
URL映射 1) 一般格式@RequestMapping(value=“/test”) 2) 可以使用模板模式映射,@RequestMapping(value=“/test/{userId}”) 3) ...
 - cnblogs用户体验评价
			
1. 是否提供良好的体验给用户(同时提供价值)? 博客园就相当于现在生活中处处可见的微博,所有人都在上面发表自己的一些看法,当然我们比较关注的是计算机编程方面的一些博客,大多数编程人员愿意分享自己的代 ...
 - ABP ModuleZero 添加角色_创建角色是报错的问题解决方案
			
ABP升级后,大概3.6.1以后,在.net framework里面,从官方下载的Module zero模板添加角色是出现下面错误. 这个问题,算是新版apb的一点小缺憾,好像在.net core的模 ...
 - Pascal-S代码注释
			
注释参考博文 http://www.cnblogs.com/luxiaodou/p/6025124.html 注释代码 https://github.com/Hesitater/Pascal-S-Co ...
 - Alpha阶段敏捷冲刺④
			
1.提供当天站立式会议照片一张. 每个人的工作 (有work item 的ID),并将其记录在码云项目管理中: 昨天已完成的工作. 改善界面设计 今天计划完成的工作. 数据库和程序的连接 后端框架的继 ...