Codeforces Round #539 (Div. 2)

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

前缀异或

上一篇:ORACLE的Copy命令和create table,insert into的比较


下一篇:Django中请求的生命周期