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
这场怎么全是数据结构题...
随机推荐
- 利用sqlmap注入测试
安装:yum install -y gitcd /usr/local && git clone https://github.com/sqlmapproject/sqlmap.gitc ...
- Elasticsearch 备忘
Elasticsearch7.0版本在查询时需要增加 “track_total_hits”:true 来强制进行准确的计数,默认为 “track_total_hits”:10000, 而且返回的hit ...
- python从零安装
一 python 1.安装python https://www.python.org/ 环境变量path添加 ;C:\Python27;C:\Python27\Lib\site-packages;C: ...
- 【NPM】常见问题解决
问题列表 问题一:npm install 执行报错 npm ERR! Unexpected end of JSON input while parsing near '...ependencies&q ...
- python中super的理解(转)
原文地址:https://www.zhihu.com/question/20040039 针对你的问题,答案是可以,并没有区别.但是这题下的回答我感觉都不够好. 要谈论 super,首先我们应该无视 ...
- UOJ#23. 【UR #1】跳蚤国王下江南 仙人掌 Tarjan 点双 圆方树 点分治 多项式 FFT
原文链接https://www.cnblogs.com/zhouzhendong/p/UOJ23.html 题目传送门 - UOJ#23 题意 给定一个有 n 个节点的仙人掌(可能有重边). 对于所有 ...
- 011 pandas的常见操作
一:对索引进行操作 1.reindex重新索引 pandas提供了一个方法来创建一个适应新索引的新对象. Series通过调用reindex方法会根据新的索引顺序重新排序,如果新的索引中存在原索引不存 ...
- utf-8和utf8的区别
utf-8 和 utf8 的区别与使用: "UTF-8" 是标准写法,php 在 Windows 系统里的英文不区分大小写,所以也可以写成 "utf-8".&q ...
- ZOJ 1109 Language of FatMouse 【Trie树】
<题目链接> 题目大意: 刚开始每行输入两个单词,第二个单词存入单词库,并且每行第二个单词映射着对应的第一个单词.然后每行输入一个单词,如果单词库中有相同的单词,则输出它对应的那个单词,否 ...
- codeforces 1058D.Vasya and Triangle (gcd)
<题目链接> <转载于 >>> > 题目大意: 给出n.m.k.求一个三角形使它的面积等于n*m/k 并且这个三角形的三个顶点所在的坐标为整数点,且顶点满 ...