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. 表单序列化json字符串和js时间格式化

    js时间格式化 new Date().format("时间格式") Date.prototype.format = function(fmt) { var o = {        ...

  2. 最全总结 | 聊聊 Python 办公自动化之 PPT(中)

    1. 前言 上一篇文章简单地介绍了 PPT 的文档结构,并使用 python-pptx 这个依赖库完成对 PPT 文档最基本的操作 最全总结 | 聊聊 Python 办公自动化之 PPT(上) 作为 ...

  3. 震惊!java中日期格式化的大坑!

    前言 我们都知道在java中进行日期格式化使用simpledateformat.通过格式 yyyy-MM-dd 等来进行格式化,但是你知道其中微小的坑吗? yyyy 和 YYYY 示例代码 @Test ...

  4. JS 学习 一

  5. 利用python 5分钟制作一款小游戏

    1.安装pygame 在命令行cmd中输入:pip install pygame ( 注:如果安装不成功,需要输入:python -m pip install --user --upgrade pip ...

  6. 阿里面试:MySQL如何设计索引更高效?

    有情怀,有干货,微信搜索[三太子敖丙]关注这个不一样的程序员. 本文 GitHub https://github.com/JavaFamily 已收录,有一线大厂面试完整考点.资料以及我的系列文章. ...

  7. 【对线面试官】Java 反射&&动态代理

    // 抽象类,定义泛型<T> public abstract class BaseDao<T> { public BaseDao(){ Class clazz = this.g ...

  8. Flutter 布局类组件:流式布局(Wrap和Flow)

    前言 把超出屏幕显示范围会自动折行的布局称为流式布局.Flutter中通过Wrap和Flow来支持流式布局,将Row换成Wrap后溢出部分则会自动折行. Wrap 接口描述 Wrap({ Key ke ...

  9. SpringMVC文件的上传与下载实现

    单文件上传 首先创建项目,开发工具是IDEA,选择Spring项目,勾选上Spring和SpringMVC. 然后命名,最后完成. 默认生成配置文件在web/WEB-INF下. 首先导入需要的jar包 ...

  10. Spark学习进度11-Spark Streaming&Structured Streaming

    Spark Streaming Spark Streaming 介绍 批量计算 流计算 Spark Streaming 入门 Netcat 的使用 项目实例 目标:使用 Spark Streaming ...