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. Android驱动-Java入门学习(java安装)

    在ubuntu 14.04上java开发环境. 下载 jdk-7u75-linux-x64.tar.gz 使用tar xvf jdk-7u75-linux-x64.tar.gz 解压 在/usr/li ...

  2. 阿里云对象存储OSS及CDN加速配置

    目录 十大云存储服务商 1. 登陆阿里云官网,开通对象存储服务 OSS 2. 创建存储空间 3. 绑定自定义域名 4. 配置阿里云CDN加速 5. 购买阿里云免费SSL证书 6. 阿里云CDN配置HT ...

  3. [ABP教程]第七章 作者:数据库集成

    Web开发教程7 作者:数据库集成 关于此教程 在这个教程系列中,你将要构建一个基于ABP框架的应用程序 Acme.BookStore.这个应用程序被用于甘丽图书页面机器作者.它将用以下开发技术: E ...

  4. 任意文件下载漏洞的接口URL构造分析与讨论

    文件下载接口的URL构造分析与讨论 某学院的文件下载接口 http://www.****.edu.cn/item/filedown.asp?id=76749&Ext=rar&fname ...

  5. uber_go_guide解析(一)

    前言 实力有限,guide啃着好费劲 原地址https://github.com/xxjwxc/uber_go_guide_cn 加我自己的体会和补充 基于Golang 1.14 正文 Interfa ...

  6. vue 侦听器watch 之 深度监听 deep

    <template> <div> <p>FullName: {{person.fullname}}</p> <p>FirstName: &l ...

  7. 【JavaWeb】JSP 页面

    JSP 页面 简介 JSP(Java Server Pages),即 Java 的服务器页面.它的主要作用是代替 Servlet 程序回传 HTML 页面的数据,因为 Servlet 程序回传 HTM ...

  8. Azure Terraform(四)状态文件存储

    一,引言 我们都知道在执行部署计划之后,当前目录中就产生了名叫 "" 的 Terraform 的状态文件,该文件中记录了已部署资源的状态.默认情况下,在执行部署计划后,Terraf ...

  9. Centos搭建Git服务端

    首先需要安装git,可以使用yum源在线安装 yum install -y git 创建一个git用户,用来运行管理git服务 adduser git 初始化git仓库(这里我们选择/home/git ...

  10. myisam崩溃后发生损坏的概率比innodb高的原因

    myisam崩溃后发生损坏的概率比innodb高的原因