首页 > 其他分享 >Codeforces Global Round 1

Codeforces Global Round 1

时间:2023-01-29 10:36:24浏览次数:42  
标签:int 题解 ll Global Codeforces long 1e6 Round

A

 

 题解:倒叙枚举即可。

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3  
 4 typedef long long ll;
 5 const ll N=1e6+3;
 6 ll b,k,a[N];
 7 void Solve()
 8 {
 9     cin>>b>>k;ll s=0,p=1;
10     for(int i=1;i<=k;i++)cin>>a[i];
11     for(int i=k;i>0;i--)s=(s+p*a[i])%2,p=p*b%2;
12     if(s%2==0)cout<<"even"<<endl;
13     else cout<<"odd"<<endl;
14 }
15 int main()
16 {
17     int T;T=1;
18     while(T--)Solve();
19 }
View Code

 B

 

 

 题解:当没有 $k$ 的限制的时候,答案就为 $n$。考虑当 $k$ 逐渐减小的时候,就贪心覆盖的最近的两个点。

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3  
 4 typedef long long ll;
 5 const ll N=1e6+3;
 6 ll n,m,k,a[N],b[N];
 7 void Solve()
 8 {
 9     cin>>n>>m>>k;ll s=n;
10     for(int i=1;i<=n;i++)cin>>a[i];
11     for(int i=1;i<n;i++)b[i]=a[i+1]-a[i]-1;
12     sort(b+1,b+n);
13     for(int i=1;i<=n-k;i++)s+=b[i];
14     cout<<s<<endl;
15 }
16 int main()
17 {
18     int T;T=1;
19     while(T--)Solve();
20 }
View Code

C

 

 

 题解:手玩几组数据后,发现除了  $2^n-1$ 这类数,其他所有数的答案都是 $2^{floor(log2(2))+1}-1$。

 

标签:int,题解,ll,Global,Codeforces,long,1e6,Round
From: https://www.cnblogs.com/Hanghang007/p/17071919.html

相关文章

  • NSS Round7_web
    概述:题目来源Round7的web4—Shadowflag。比赛的时候也没做出来,但是也花费了很长时间去做这题和思考,所以赛后复现记录一下,自己遇到的坑及收获的一些技巧,知识等。感谢陈橘墨......
  • Educational Codeforces Round 2 个人总结A-D
    EducationalCodeforcesRound3A.USBFlashDrives降序排序后,贪心,甚至不会爆longlongvoidsolve(){intn,m;cin>>n>>m;vector<int>a(n);for(......
  • NSSCTF Round7 WP
    NSSCTFRound7WP还不错,一个全场唯一解一个二血,队友还拿了一个一血(KoH)两个二血WebF|ez_RCE|Doxxxaction=1'&data=;cat/flag%23'2|OoO|DoxxxPOST/Ns_SC......
  • Codeforces Round #801 (Div. 2) and EPIC Institute of Technology Round A - D
    题目链接A#include<iostream>#include<cstring>#include<algorithm>usingnamespacestd;#defineintlonglongconstintN=1e3+10;intn,m;intg[N][N......
  • Codeforces Round #847 F
    F.TimofeyandBlack-WhiteTree题链因为是一棵树的形式我们不妨考虑dpdp[u]表示u节点子树内黑点离u的最近距离我们每添加一个点当然会更新他及他链上面父亲的dp值......
  • Codeforces Round #816 (Div. 2)
    D.2+doors要让字典序最小就要让每个数字在满足条件的同时都尽可能的小并且排在前面的数字变小的优先级要比排在后面的数字的优先级更大。\[\begin{aligned}1\operator......
  • Codeforces Round #847 (Div. 3)
    E.VladandaPairofNumbers题目抽象为给\(n\)\((1\len\le2^{29})\),求\(x\)满足\((n-x)\oplus(n+x)=n\),输出\(n-x\)和\(n+x\)。显然\(n\)为奇数肯定不行......
  • CF 1790E. Vlad and a Pair of Numbers_Codeforces Round #847 (Div. 3)
    给出整数x,求一对整数(a,b),满足:\(a\bigoplusb=x\),\(\frac{a+b}{2}=x\)(\(\frac{a+b}{2}\)不四舍五入,也就是\(2\mida+b\))如果不存在这样的(a,b)输出-1分析:如果x的最......
  • Educational Codeforces Round 2 个人总结A-E
    EducationalCodeforcesRound2A.ExtractNumbers简单的模拟boolcheck(stringop){ if(op.size()==1&&op[0]=='0') returntrue; if(op.size()==0||(op[0]<'1......
  • #0031. Educational Codeforces Round 1
    AB简单题C是计算几何,但核心解法很像sgnoi某年的t1,即与其考虑所有pairs,不如只考虑所有相邻的,这样复杂度就从\(O(N^2)\)降到了O(N)(如果不考虑排序的复杂度的话)。不过这......