codeforces 850B Arpa and a list of numbers
来源:互联网 发布:mac怎么关闭软件 编辑:程序博客网 时间:2024/05/19 02:03
#include <bits/stdc++.h>using namespace std;typedef long long LL;const int MAXN = 2e6;const LL INF = 1e18;int a[MAXN];LL s[MAXN],used[MAXN];int main(){LL n,x,y;cin>>n>>x>>y;int p = x/y;for(int i = 1;i <= n;i++){int tmp;scanf("%d",&tmp); a[tmp]++;s[tmp] += (LL)tmp;}LL ans = INF;for(int i = 1;i < MAXN;i++)a[i] += a[i-1],s[i] += s[i-1];for(int i = 2;i <= 1000000;i++){if(used[i]) continue;LL tmp = 0;for(int j = i;j <= 1000000 + i;j += i){used[j] = 1;int k = max(j - i + 1,j - p );tmp +=((LL)(a[j] - a[k-1])*j - (s[j] - s[k-1]))*y + (LL)(a[k-1] - a[j-i])*x;}ans = min(ans,tmp);}cout<<ans<<endl;return 0;}/*45 11 17 17 17*/
阅读全文
1 0
- codeforces 850B Arpa and a list of numbers
- Codeforces Round #432 B. Arpa and a list of numbers
- Codeforces Round #432 (Div. 2) D 850B Arpa and a list of numbers(gcd 枚举)
- Codeforces Round #432 (Div. 1): B. Arpa and a list of numbers
- codeforces 580B Arpa and a list of numbers 前缀和+思维+分块 (调和级数)
- Codeforces Round #432 (Div. 1) B. Arpa and a list of numbers
- Codeforces 851D. Arpa and a list of numbers
- CF850B-Arpa and a list of numbers
- CF_850B Arpa and a list of numbers
- Codeforces Round #432 (Div. 2) D. Arpa and a list of numbers E. Arpa and a game with Mojtaba
- Codeforces Codeforces Round #432 (Div. 2 D ) Arpa and a list of numbers 爆搜+剪枝
- Codeforces Codeforces Round #432 (Div. 2 D ) Arpa and a list of numbers
- codeforces 851 D. Arpa and a list of numbers(前缀和+bruteforce)
- 解题报告:Codeforces Round #432 (Div. 2) D. Arpa and a list of numbers 暴力
- Codeforces 851D Arpa and a list of numbers【思维+前缀和】
- Codeforces 432 Div. 2-D-Arpa and a list of numbers(枚举倍数求GCD)
- Codeforces 851 D. Arpa and a list of numbers(技巧)
- Codeforces 851D Arpa and a list of numbers Round #432 (Div. 2
- SpringMVC:配置过程
- vim 用ctags时增加当前文件包含的boost头文件属性跳转
- ubutun查询ip地址
- matlab2c使用c++实现matlab函数系列教程-geomean函数
- Java学习路线图
- codeforces 850B Arpa and a list of numbers
- mysql学习----索引
- jquery $.ajax status为200 却调用了error方法
- ION框架学习(一)
- 使用AIDL,客户端调用和Service回调,以及一些需要注意的细节
- Java获取代理地址和端口
- 利用生产者消费者模式实现HTTP接口的异步调用
- 使用openlayers 3 在线加载天地图及GeoServer发布的地图
- linux下mysql开启远程访问权限及防火墙开放3306端口