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. 来一个使用sysbench测试cpu性能的简单脚本

    #!/bin/bash for ((i=1; i<16; i++)); do sysbench cpu run --cpu-max-prime=10000 --threads=4 --time= ...

  2. ExceptionLess的MVC调用

    引用 <package id="Exceptionless" version="4.2.1989" targetFramework="net46 ...

  3. [转]Xshell在按delete,backspace键产生乱码(不可用)的解决方法

    Xshell在按delete,backspace键产生乱码的解决方法 当我们用Xshell登录进入linux后,在普通模式下,对输入进行删除等操作没有问题. 而在运行中,按delete,backspa ...

  4. bash: cannot create temp file for here-document: Read-only file system

    文件系统被强制只读问题,第一眼看到百度了一下,说可能磁盘坏了.卧槽我都吓懵了系统盘坏了,闹着玩呢,然后接着查资料,排查 mount 查看所有挂载,发现根目录的挂载权限是ro只读. /dev/sda2 ...

  5. net core体系-web应用程序-4net core2.0大白话带你入门-10asp.net core session的使用

    asp.net core session的使用   Session介绍 本文假设读者已经了解Session的概念和作用,并且在传统的.net framework平台上使用过. Asp.net core ...

  6. 2018牛客网暑假ACM多校训练赛(第十场)D Rikka with Prefix Sum 组合数学

    原文链接https://www.cnblogs.com/zhouzhendong/p/NowCoder-2018-Summer-Round10-D.html 题目传送门 - https://www.n ...

  7. 环境变量误删path找回方法与mysql基础命令

    环境变量误删path找回方法用户path:%USERPROFILE%\AppData\Local\Microsoft\WindowsAppsWin+R 输入regedit 打开注册表(开始-运行里输入 ...

  8. 队列queue实现线程的消费者和生产者

    import threading import queue import random import time qq = queue.Queue(4) #实例化一个队列,因为是一个进程的线程,所以共资 ...

  9. box-shadow阴影 三面显示

    想弄个只显示三面的阴影效果,网上一搜没有解决根本问题,最后还是在css3演示里面找到方法http://www.css88.com/tool/css3Preview/Box-Shadow.html 我把 ...

  10. Hdu-2008

    杭电OJ-2008 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2008 #include<stdio.h> int main() { i ...