Codeforces Round #539 (Div. 2)
Codeforces Round #539 (Div. 2)
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define lson i<<1
#define rson i<<1|1
#define LS l,mid,lson
#define RS mid+1,r,rson
#define mem(a,x) memset(a,x,sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define ll long long
#define ull unsigned long long
#define lowbit(x) (x&-x)
#define pb(x) push_back(x)
#define enld endl
#define mian main
#define itn int
#define prinft printf
#pragma GCC optimize(2)
//#pragma comment(linker, "/STACK:102400000,102400000")
const double PI = acos (-1.0);
const int INF = 0x3f3f3f3f;
;
;
;
;
using namespace std;
int n,v;
int main() {
cin>>n>>v;
<=v) {
cout<<n-<<endl;
;
}
int ans=v;
;i<=n--v+;++i) ans+=i;
cout<<ans<<endl;
}
A - Sasha and His Trip
B - Sasha and Magnetic Machines
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define lson i<<1
#define rson i<<1|1
#define LS l,mid,lson
#define RS mid+1,r,rson
#define mem(a,x) memset(a,x,sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define ll long long
#define ull unsigned long long
#define lowbit(x) (x&-x)
#define pb(x) push_back(x)
#define enld endl
#define mian main
#define itn int
#define prinft printf
#pragma GCC optimize(2)
//#pragma comment(linker, "/STACK:102400000,102400000")
const double PI = acos (-1.0);
const int INF = 0x3f3f3f3f;
;
;
;
;
using namespace std;
],n,sum,tmp,Min;
vector<int> p;
void init() {
mem(vis,),sum=,Min=INF;
}
void Solve(int n) {
p.clear();
; i<=n; i++) {
) {
p.push_back(i);
}
}
}
int main() {
init();
scanf("%d",&n);
; i<=n; ++i) {
scanf("%d",&tmp);
sum+=tmp;
vis[tmp]=;
Min=min(Min,tmp);
}
int ans=sum;
; i<=; ++i)
if(vis[i]) {
Solve(i);
) continue;
; j<p.size(); ++j) {
ans=min(ans,sum-(i-i/p[j])+Min*p[j]-Min);
// cout<<j<<' '<<p[j]<<endl;
}
}
cout<<ans<<endl;
}
B - Sasha and Magnetic Machines
1、交换律
2、结合律(即(a^b)^c == a^(b^c))
3、对于任何数x,都有x^x=0,x^0=x
4、自反性 A XOR B XOR B = A xor 0 = A
前缀异或
Codeforces Round #539 (Div. 2)的更多相关文章
- 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) 题目链接:https://codeforces.com/contest/1113 A. Sasha and His Trip 题意: n个 ...
- Codeforces Round #539 (Div. 2) D 思维
https://codeforces.com/contest/1113/problem/D 题意 将一个回文串切成一段一段,重新拼接,组成一个新的回文串,问最少切几刀 题解 首先无论奇偶串,最多只会切 ...
- Codeforces Round #539 (Div. 2) 异或 + dp
https://codeforces.com/contest/1113/problem/C 题意 一个n个数字的数组a[],求有多少对l,r满足\(sum[l,mid]=sum[mid+1,r]\), ...
- 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 ...
- Codeforces Round #539 Div. 1
A:即求长度为偶数的异或和为0的区间个数,对前缀异或和用桶记录即可. #include<iostream> #include<cstdio> #include<cmath ...
- 20191031 Codeforces Round #539 (Div. 1) - Virtual Participation
这场怎么全是数据结构题...
随机推荐
- Centos+Redis 集群
Redis 3.2.6集群搭建 Redis3.0版本之后支持Cluster. 1.1.redis cluster的现状 目前redis支持的cluster特性: 1):节点自动发现 2):slave- ...
- maven依赖jar导出消失问题
问题:maven依赖jar导出消失问题 新创新的Maven管理的项目,使用的模板是maven-archetype-quickstart,设置maven管理的jar导出时,如下 在每次”update ...
- KnocoutJs+Mvc+BootStrap 学习笔记(Mvc)
Mvc 1.Html 增加扩展方法 using System.Web.Mvc; namespace KnockoutBootstrapMvc.Entensions { public static ...
- JS获取地址栏的参数值
function GetQueryString(name){ var reg = new RegExp("(^|&)"+ name +"=([^&]*)( ...
- ip访问网站和localhost访问网站中top使用
对于相对定位,使用margin-top不用简单使用top. top在localhost中能正常显示,在ip访问时会出现多余空白. margin-top不管是localhost中还是ip中都能正常显示.
- Codeforces 1012D AB-Strings 贪心
原文链接https://www.cnblogs.com/zhouzhendong/p/CF1012D.html 题目传送门 - CF1012D 题意 给定字符串 $s,t$ ,其中只包含小写字母 $a ...
- 03. Pandas 2| 时间序列
1.时间模块:datetime datetime模块,主要掌握:datetime.date(), datetime.datetime(), datetime.timedelta() 日期解析方法:pa ...
- scrapy 手动编写模板
import scrapy class Tzspider(scrapy.Spider): # spider的名字,唯一 name = 'tz' # 初始url列表 start_urls = ['htt ...
- 图解安装Debian 9.5全过程
本文将为你带来安装Debian 9.5 GNU/Linux的教程,安装全过程图文并茂讲解.安装Debian 9.5可以把ISO文件下载下来刻录成DVD安装或者采用虚拟机安装等等方法. 一.下载Debi ...
- 在用UEditor往后台传数据写入数据库时,出现错误:从客户端(NewsContent="<p><img src="http://...")中检测到有潜在危险的 Request.。。。
解决办法: 把传数据的方式换了一下,加上 [ValidateInput(false)]就不报错了. 建议看看这个:http://www.360doc.com/content/10/0521/15/46 ...