Link~

题面差评,整场都在读题

A

根据奇偶性判断一下即可。

#include<bits/stdc++.h>
#define ll long long
#define N
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define inf 0x3f3f3f3f
#define pb push_back
#define mp make_pair
#define lowbit(i) ((i)&(-i))
#define VI vector<int>
using namespace std;
int t,n;
string s;
int main(){
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
cin>>t;
while(t--){
cin>>n;
cin>>s;
int odd,even;odd = even = -1;
if(n&1){
rep(i,0,n-1){
if((i&1)==0){
int v = s[i]-'0';
if(v&1) odd = 1;
else even = 1;
}
}
if(odd != -1) puts("1");
else puts("2");
}else{
rep(i,0,n-1){
if((i&1)==1){
int v = s[i]-'0';
//cout << "v: " <<v << endl;
if(v&1) odd = 1;
else even = 1;
}
}
if(even != -1) puts("2");
else puts("1");
} }
return 0;
}

B

神必题意,读了快半小时才明白题意。

看着题目给的图的找个规律就行了。

#include<bits/stdc++.h>
#define int long long
#define N 1000015
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define inf 0x3f3f3f3f
#define pb push_back
#define mp make_pair
#define lowbit(i) ((i)&(-i))
#define VI vector<int>
using namespace std;
int t,n,x,val[N];
int qpow(int a,int b){
int res = 1;
while(b){
if(b&1) res = res*a;
a = a*a;
b>>=1;
}
return res;
}
signed main(){
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
cin>>t;n = 31;
rep(i,1,n) val[i] = val[i-1]*2+qpow(4,i-1);
rep(i,1,n) val[i] += val[i-1];//,cout << val[i] << endl;
while(t--){
cin>>x;
int l = 1,r = n,ans = 0;
while(l+3 < r){
int mid = (l+r)>>1;
if(val[mid] <= x) l = mid;
else r = mid;
}
rep(i,l,r){
if(val[i] <= x) ans = max(ans,i);
}
cout << ans << endl;
}
return 0;
}

C

大力分类讨论题,WA了好多发

#include<bits/stdc++.h>
#define int long long
#define N 1005
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define inf 0x3f3f3f3f
#define pb push_back
#define mp make_pair
#define lowbit(i) ((i)&(-i))
#define VI vector<int>
using namespace std;
int t,n,a[N];
signed main(){
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
cin>>t;
while(t--){
int ans = inf,cur,ff = 0;
cin>>n>>cur;
rep(i,1,n) cin>>a[i];
int sum = 0;rep(i,1,n) sum += a[i];
rep(i,1,n) if(a[i] == cur) ff++;
if(n*cur == sum) ans = min(ans,1ll);
if(ff == n) ans = min(ans,0ll);
if(ff > 1){
ans = min(ans,1ll);
}else{
ans = min(ans,2ll);
}
int left = n-ff;
if(left < n) ans = min(ans,1ll);
if(sum%n == 0){
if(ff) ans = min(ans,1ll);
}
cout << ans << endl;
}
return 0;
}

D

贪心构造

#include<bits/stdc++.h>
#define ll long long
#define N 100015
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define inf 0x3f3f3f3f
#define pb push_back
#define mp make_pair
#define lowbit(i) ((i)&(-i))
#define VI vector<int>
using namespace std;
int n,a[N],b[N];
int main(){
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
cin>>n;
rep(i,1,n) cin>>a[i];
sort(a+1,a+n+1);int l = 1,r = n/2+1;
rep(i,1,n){
if(i&1) b[i] = a[r++];
else b[i] = a[l++];
}
int cnt = 0;
rep(i,2,n-1){
if(b[i] < b[i-1]&&b[i] < b[i+1]) cnt++;
}
cout << cnt << endl;
rep(i,1,n) cout << b[i] << ' ';
return 0;
}

E

特判\(n = p*q\)的情况,其中\(p,q\)是质数,答案为\(1\),直接输出即可。

否则答案为零,

这样围成一个圈就行了。

垃圾场,让人挺不爽的,因为奇怪的原因被区分,可能是手速和英语不太行。

Codeforces Round #671 (Div. 2) (A~E)的更多相关文章

  1. Codeforces Round #316 (Div. 2) (ABC题)

    A - Elections 题意: 每一场城市选举的结果,第一关键字是票数(降序),第二关键字是序号(升序),第一位获得胜利. 最后的选举结果,第一关键字是获胜城市数(降序),第二关键字是序号(升序) ...

  2. Codeforces Round #240 (Div. 2)(A -- D)

    点我看题目 A. Mashmokh and Lights time limit per test:1 secondmemory limit per test:256 megabytesinput:st ...

  3. Codeforces Round #324 (Div. 2) (哥德巴赫猜想)

    题目:http://codeforces.com/problemset/problem/584/D 思路: 关于偶数的哥德巴赫猜想:任一大于2的偶数都可写成两个素数之和. 关于奇数的哥德巴赫猜想:任一 ...

  4. Codeforces Round #395 (Div. 2)(未完)

    2.2.2017 9:35~11:35 A - Taymyr is calling you 直接模拟 #include <iostream> #include <cstdio> ...

  5. B. Nirvana Codeforces Round #549 (Div. 2) (递归dfs)

    ---恢复内容开始--- Kurt reaches nirvana when he finds the product of all the digits of some positive integ ...

  6. 【Codeforces】Codeforces Round #491 (Div. 2) (Contest 991)

    题目 传送门:QWQ A:A - If at first you don't succeed... 分析: 按照题意模拟 代码: #include <bits/stdc++.h> usin ...

  7. 【Codeforces】Codeforces Round #492 (Div. 2) (Contest 996)

    题目 传送门:QWQ A:A - Hit the Lottery 分析: 大水题 模拟 代码: #include <bits/stdc++.h> using namespace std; ...

  8. Codeforces Round #524 (Div. 2)(前三题题解)

    这场比赛手速场+数学场,像我这样读题都读不大懂的蒟蒻表示呵呵呵. 第四题搞了半天,大概想出来了,但来不及(中途家里网炸了)查错,于是我交了两次丢了100分.幸亏这次没有掉rating. 比赛传送门:h ...

  9. Codeforces Round #624 (Div. 3)(题解)

    Codeforces Round #624 (Div.3) 题目地址:https://codeforces.ml/contest/1311 B题:WeirdSort 题意:给出含有n个元素的数组a,和 ...

随机推荐

  1. CTF:从0到1 -> zero2one

    本篇blog首发0xffff论坛(CTF:从0到1->zero2one - 0xFFFF),中间有各位大佬补充,搬到了个人博客CTF:从0到1 -> zero2one | c10udlnk ...

  2. 「译」使用 System.Net.Http.Json 高效处理Json

    在这篇文章,我将介绍一个名为 System.Net.Http.Json 的扩展库,它最近添加到了 .NET 中,我们看一下这个库能够给我们解决什么问题,今天会介绍下如何在代码中使用. 在此之前我们是如 ...

  3. VoltDB成功入选CNCF Landscape云原生数据库全景图

    近日,VoltDB正式入选 CNCF Landscape(可能是目前其中唯一的关系型分布式内存数据库).此次VoltDB 进入 CNCF Landscape,意味着 VoltDB 正式成为了 CNCF ...

  4. Ubuntu/Liinux睡眠无法唤醒解决方法:ACPI设置

    最近给笔记本换了一个固态,顺便就重装了一下系统,版本是Ubuntu 20.10.装完之后各种功能基本都是正常的,触摸板轻触单击.双指右键等功能开箱即用.但是在安装完最新的Nvidia驱动之后就出现了问 ...

  5. mysql修改sql_mode为宽松模式

    sql_mode ANSI TRADITIONAL STRICT_TRANS_TABLES sql_mode为空 最宽松的模式, 即使有错误既不会报错也不会有警告️ ANSI 宽松模式,对插入数据进行 ...

  6. Redis核心原理-简单动态字符串SDS

    SDS简介 Redis是C语言编写的,但没有使用c语言的字符串结构,而是自己实现了一套简单动态字符串 simple dynamic string 简称SDS,SDS兼容C语言的字符串类型,原理类似Ja ...

  7. Mac M1原生(ARM64)Golang dev&debug

    前言 通过本文最终实现了在M1芯片的Mac mini上的Goland的开发,并通过编译源码解决了无法DEBUG的问题. Go 1.16版将正式支持Apple Silicon M1芯片,即arm64架构 ...

  8. Docker 镜像仓库使用(六)

    阿里云docker 容器镜像服务: www.aliyun.com 1 服务开通 (开通的时候要求创建密码请牢记此密码) 2 创建命名空间 3 创建镜像仓库 4 linux 客户端登录 登录: dock ...

  9. python学习笔记 | PyCharm出现卡顿解决方法

    问题:使用pycharm时常出现 the IDE is running low on memory 的问题 表示pycharm这款IDE使用内存不足 需要在系统内存充足的情况下扩充IDE memory ...

  10. MySQL where 条件字句查询

    where 条件字句 搜索条件可由一个或多个逻辑表达式组成 , 结果一般为布尔值 逻辑运算符 运算符 语法 描述 and && a and b a && b 逻辑与 两 ...