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. Oracle中除数为0的两种解决办法(decode与nullif)

    Oracle中Decode函数,语句DECODE(tag,''ZCGS'',0,1)=decode(''@corp-No@'',''6010'',1,0) decode(字段或字段的运算,值1,值2, ...

  2. Linux下删除文件名带有空格的文件

    1.使用单引号将文件名括起来进行操作: rm '2018-08-07 17-29-48.png'

  3. 686. Repeated String Match判断字符串重复几次可以包含另外一个

    public static int repeatedStringMatch(String A, String B) { //判断字符串a重复几次可以包含另外一个字符串b,就是不断叠加字符串a直到长度大 ...

  4. Mapreduce实例--二次排序

    前言部分: 在Map阶段,使用job.setInputFormatClass定义的InputFormat将输入的数据集分割成小数据块splites,同时InputFormat提供一个RecordRed ...

  5. 多线程并行_countDown

    /** * 首次启动加载数据至缓存 */ public class ApplicationStartTask { private static Logger logger = LoggerFactor ...

  6. 茅坑杀手与Alias Method离散采样

    说起Alias,你可能第一个联想到的是Linux中的Alias命令,就像中世纪那些躲在茅坑下面(是真的,起码日本有粪坑忍者,没有马桶的年代就是社会的噩梦)进行刺杀的杀手一样,让人防不胜防,对于那些被这 ...

  7. FFT原理及C++与MATLAB混合编程详细介绍

    一:FFT原理 1.1 DFT计算 在一个周期内的离散傅里叶级数(DFS)变换定义为离散傅里叶变换(DFT). \[\begin{cases} X(k) = \sum_{n=0}^{N-1}x(n)W ...

  8. phoenix启动报错:org.apache.phoenix.exception.PhoenixIOException: SYSTEM.CATALOG

    错误: org.apache.phoenix.exception.PhoenixIOException: SYSTEM.CATALOG at org.apache.phoenix.util.Serve ...

  9. 一个上传图片,预览图片的小demo

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  10. 在阿里云托管的k8s上使用nas做动态存储

    前言 关于aliyun托管k8s的存储插件主要有两种: CSI # kubectl get pod -n kube-system | grep csi-plugin csi-plugin-8bbnw ...