Codeforces Round #539--1113B - Sasha and Magnetic Machines
https://codeforces.com/contest/1113/problem/B
思想不难,但是在比较大小的时候,我选择了很笨的方法,我用两个数变化之后的差值大小来进行选择,然后最后再进行数组的更改,最后求和。
实际上,可以先求和,在每次运算之前,减去两个数,然后再把处理后的两个数加上,比较和的大小。
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int> num;
vector<int> isPrime(int d){
vector<int> res;
for(int i=;i*i<=d;i++){
if(d%i==){
res.push_back(i);
if(i!=d/i)
res.push_back(d/i);
}
}
return res;
}
int main(){
cin>>n;
num.resize(n);
for(int i=;i<n;i++)
cin>>num[i];
int sum=accumulate(num.begin(),num.end(),);
int minNum=*min_element(num.begin(),num.end());
int ress=sum;
for(int i=;i<num.size();i++){
vector<int> res=isPrime(num[i]);
for(int j=;j<res.size();j++){
int c=res[j];
int tmpSum=sum-minNum-num[i];
tmpSum+=minNum*c+num[i]/c;
ress=min(ress,tmpSum);
}
}
cout<<ress<<endl;
return ;
}
Codeforces Round #539--1113B - Sasha and Magnetic Machines的更多相关文章
- Codeforces Round #539 (Div. 2) - D. Sasha and One More Name(思维)
Problem Codeforces Round #539 (Div. 2) - D. Sasha and One More Name Time Limit: 1000 mSec Problem ...
- Codeforces Round #539 (Div. 2) - C. Sasha and a Bit of Relax(思维题)
Problem Codeforces Round #539 (Div. 2) - C. Sasha and a Bit of Relax Time Limit: 2000 mSec Problem ...
- Codeforces Round #539 (Div. 2)
Codeforces Round #539 (Div. 2) A - Sasha and His Trip #include<bits/stdc++.h> #include<iost ...
- Codeforces Round #539 (Div. 2) 题解
Codeforces Round #539 (Div. 2) 题目链接:https://codeforces.com/contest/1113 A. Sasha and His Trip 题意: n个 ...
- Codeforces Round #539 Div1 题解
Codeforces Round #539 Div1 题解 听说这场很适合上分QwQ 然而太晚了QaQ A. Sasha and a Bit of Relax 翻译 有一个长度为\(n\)的数组,问有 ...
- Codeforces Round #539Ȟȟȡ (Div. 1) 简要题解
Codeforces Round #539 (Div. 1) A. Sasha and a Bit of Relax description 给一个序列\(a_i\),求有多少长度为偶数的区间\([l ...
- Codeforces Round #539 div2
Codeforces Round #539 div2 abstract I 离散化三连 sort(pos.begin(), pos.end()); pos.erase(unique(pos.begin ...
- Codeforces Round #539 (Div. 2) C. Sasha and a Bit of Relax(前缀异或和)
转载自:https://blog.csdn.net/Charles_Zaqdt/article/details/87522917 题目链接:https://codeforces.com/contest ...
- Codeforces Round #539 (Div. 2) C Sasha and a Bit of Relax
题中意思显而易见,即求满足al⊕al+1⊕…⊕amid=amid+1⊕amid+2⊕…⊕ar且l到r的区间长为偶数的这样的数对(l,r)的个数. 若al⊕al+1⊕…⊕amid=amid+1⊕amid ...
随机推荐
- 工具函数(获取url , 时间格式化,随机数)
(function(window,$){ function Tools() { } // url Tools.prototype.readUrlToParams = function() { var ...
- 批量IP自动ping脚本
批量IP自动ping脚本ping.sh 在同一目录新建一个名为pingip的文件,并以每行一个IP的方式罗列.使用sh命令执行ping.sh #!/bin/bash IP_LIST=`cat ping ...
- jpg转yuv420抠图后转为jpg
最近遇到个需求,已有全景图和其中的人脸坐标,将人脸小图从全景图中抠出来,最开始使用libjpeg,奈何使用libjpeg将jpg转为yuv420的资料实在少,libjpeg自身的readme和exam ...
- itextsharp图片生成pdf模糊问题解释
I forget to mention that I' am using itextsharp 5.0.2. It turned out that PDF DPI = 110, which means ...
- nginx的一次工作记录
upstream fazhi_ui{ server ; } upstream fazhi_api{ server ; } server { listen ; server_name localhost ...
- ArcPy开发教程1-面向ArcGIS的Python语言基础
ArcPy开发教程1-面向ArcGIS的Python语言基础 联系方式:谢老师,135-4855-4328,xiexiaokui#qq.com 第一节课 时间2019年2月26日 上午第一节 讲解:A ...
- [Ting's笔记Day6]活用套件carrierwave gem:(1)在Rails实现图片上传功能
carrierwave是一款经典的图片上传套件,本篇的目标是先在本地端(development)的rails项目试成功gem. (预计中集的进度会练习怎么利用Amazone S3架设图片上传Host, ...
- CAFE: a computational tool for the study of gene family evolution
1.摘要 摘要:我们提出了CAFE(计算分析基因家族进化),这是一个统计分析基因家族进化规模的工具.它使用随机的出生和死亡过程来模拟一个系统发育过程中基因家族大小的进化.对于一个特定的系统发育树,并给 ...
- Spring获取bean工具类,可用于在线程里面获取bean
Spring获取bean工具类,可用于在线程里面获取bean import java.util.Locale; import org.springframework.beans.BeansExcept ...
- Block学习总结
最近网上浏览了一些关于Block的文章,自己进行一下消化吸收. Void (^blockName)(parma)-> Block声明 Void (^) (parma){}; ->Bloc ...