Codeforces Round #539 (Div. 2)

A - Sasha and His Trip

 #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

Sasha and a Bit of Relax

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)的更多相关文章

  1. 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 ...

  2. 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 ...

  3. Codeforces Round #539 (Div. 2) 题解

    Codeforces Round #539 (Div. 2) 题目链接:https://codeforces.com/contest/1113 A. Sasha and His Trip 题意: n个 ...

  4. Codeforces Round #539 (Div. 2) D 思维

    https://codeforces.com/contest/1113/problem/D 题意 将一个回文串切成一段一段,重新拼接,组成一个新的回文串,问最少切几刀 题解 首先无论奇偶串,最多只会切 ...

  5. Codeforces Round #539 (Div. 2) 异或 + dp

    https://codeforces.com/contest/1113/problem/C 题意 一个n个数字的数组a[],求有多少对l,r满足\(sum[l,mid]=sum[mid+1,r]\), ...

  6. 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 ...

  7. 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 ...

  8. Codeforces Round #539 Div. 1

    A:即求长度为偶数的异或和为0的区间个数,对前缀异或和用桶记录即可. #include<iostream> #include<cstdio> #include<cmath ...

  9. 20191031 Codeforces Round #539 (Div. 1) - Virtual Participation

    这场怎么全是数据结构题...

随机推荐

  1. 跳跃表Skip List的原理

    1.二分查找和AVL树查找 二分查找要求元素可以随机访问,所以决定了需要把元素存储在连续内存.这样查找确实很快,但是插入和删除元素的时候,为了保证元素的有序性,就需要大量的移动元素了.如果需要的是一个 ...

  2. Flink--输入数据集Data Sources

    flink在批处理中常见的source flink在批处理中常见的source主要有两大类. 1.基于本地集合的source(Collection-based-source) 2.基于文件的sourc ...

  3. sparkSQL将谓词推入kudu引擎

    kudu之所以执行非常快速,可以用来替代HDFS和Hbase等,一个主要原因是,我们可以将普通SQL中的谓词推入kudu引擎,这样kudu查询数据会变的非常快: 将谓词评估推入Kudu引擎可以提高性能 ...

  4. k8s 廖老师的分享

    https://mp.weixin.qq.com/s/7o8QxGydMTUe4Q7Tz46Diw

  5. 高性能之html

    下面是alloyteam的总结,还是那句老话站在巨人的肩膀上看的远. 避免使用Iframe Iframe也叫内联frame,可以把一个HTML文档嵌入到另一个文档中.使用iframe的好处是被嵌入的文 ...

  6. Codeforces 109D String Transformation 字符串 哈希 KMP

    原文链接https://www.cnblogs.com/zhouzhendong/p/CF109D.html 题目传送门 - CF109D 题意 给定两个字符串 $a,b$ ,求一组 $i,j$ 使得 ...

  7. 扩展中国剩余定理 (exCRT) 的证明与练习

    原文链接https://www.cnblogs.com/zhouzhendong/p/exCRT.html 扩展中国剩余定理 (exCRT) 的证明与练习 问题模型 给定同余方程组 $$\begin{ ...

  8. Codeforces Gym100543B 计算几何 凸包 线段树 二分/三分 卡常

    原文链接https://www.cnblogs.com/zhouzhendong/p/CF-Gym100543B.html 题目传送门 - CF-Gym100543B 题意 给定一个折线图,对于每一条 ...

  9. NN:神经网络实现识别手写的1~9的10个数字—Jason niu

    import numpy as np from sklearn.datasets import load_digits from sklearn.metrics import confusion_ma ...

  10. Effective前端1---chapter 1 HTML/CSS优化

    最近在读高效前端:web高效编程与优化实践,借此本书的感受总结下前端代码与性能优化,纯属自己见解,如有错误,欢迎指出. 1.能用HTML/CSS解决的问题就不要用js 场景1:鼠标悬浮时显示 鼠标悬浮 ...