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 ...
随机推荐
- JavaWeb——XML转义符字
被<![CDATA[]]>这个标记所包含的内容将表示为纯文本,比如<![CDATA[<]]>表示文本内容“<”. 此标记用于xml文档中,我们先来看看使用转义符的 ...
- 删除已经提交到远程仓库的gitignore文件
亲们支持我的新博客哦==>地址(以后更新会尽量在新博客更新,欢迎大家访问加入我的后宫w) ) gitignore里新添加了需要过滤的文件,但是之前已经提交到了远程分支 解决方法: # 1.为避免 ...
- 浅谈Cookie与Session技术
一.什么是状态管理 将客户端与服务器之间多次交互当做一个整体来看,并且将多次交互所涉及的数据(状态)保存下来. 会话:当用户打开浏览器,访问多个WEB资源,然后关闭浏览器的过程,称之为一个会话,选 ...
- redis-单线程架构
单线程模型: redis中的数据结构并不全是简单的kv,还有list.hash等复杂的结构,这些结构很可能会进行细粒度的操作,比如在很长的列表偶棉添加一个元素,在hash当中或者删除一个对象,这样的一 ...
- profile default1
DEVPISAP01:/sapmnt/ISD/profile # more ISD_J20_SHADEVEAIAP01 SAPSYSTEMNAME = ISD SAPSYSTEM = 20 INSTA ...
- 接口测试工具postman/jmeter基本使用
一.接口的分类: 最常用的两种接口webservice接口和http api接口:1.webservice接口走soap协议通过http传输,请求报文和返回报文都是XML格式,现在测试的时候都通过工具 ...
- VULKAN学习资料
1,中文开发教程:https://www.cnblogs.com/heitao/p/7193853.html
- 微擎系统jssdk系统快速签名变量
jssdkconfig = {php echo json_encode($_W['account']['jssdkconfig']);} || { jsApiList:[] }; jssdkco ...
- java学习笔记(七):for循环
java的for循环和c++的for循环类似 public class Test { public static void main(String args[]) { for(int x = 10; ...
- 实验吧“解码磁带”的write up
在“实验吧”的做CTF题时遇到的一道题,地址在这里:http://ctf5.shiyanbar.com/misc/cidai.html 因为正在学python,做这道题的时候正好用python写个简单 ...