比赛链接:https://codeforces.com/contest/1419

https://codeforces.com/contest/1419/problems

A. Digit Game

Example

input

4
1
2
1
3
3
102
4
2069

output

2
1
1
2

题意:

Raze and Breach参加比赛,给定一个 \(n\) 位的数字(从高位到低位 \(14\)~ \(n\)),Raze只能标记奇数位的数字,而Breach只能标记偶数的值,如果存在当仅剩一个未标记的数字时,比赛结束。 如果最后一位数字是奇数,则Raze获胜,否则Breach获胜。

#include<bits/stdc++.h>
using namespace std;
int _, n; string s;
void solve() {
cin >> n >> s;
bool f1 = false, f2 = false;
for (int i = 0; i < n; i += 2)if ((s[i] - '0') % 2 == 1)f1 = true;
for (int i = 1; i < n; i += 2)if ((s[i] - '0') % 2 == 0)f2 = true;
if (n % 2) puts(f1 ? "1" : "2");
else puts(f2 ? "2" : "1");
}
int main() {
//freopen("in.txt", "r", stdin);
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> _; while (_--)solve();
}

B. Stairs

Example

input

4
1
8
6
1000000000000000000

output

1
2
1
30

思路:

待补

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll _, n, ans, now;
void solve() {
cin >> n;
ans = 2, now = 0;
while ((ans - 1) * ans / 2 <= n)n -= (ans - 1) * ans / 2, now++, ans *= 2;
cout << now << endl;
}
int main() {
//freopen("in.txt", "r", stdin);
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> _; while (_--)solve();
}

D1. Sage's Birthday (easy version)

https://codeforces.com/problemset/problem/1419/D1

现在有 n 个数,对 a[] 重新排序,使得好数最多

好数的定义:在数组中比相邻的两个数都小,则称为好数,当然数组最左边和最右边的数不能称之为好数

可以保证在数组 a 中,所有的数都是不相同的

观察好数定义,要在数组中相邻的两个数都小,利用样例举例

5
1 2 3 4 5 (这个时候即使乱序也没事,需要sort) 如果我们先从2开始放入b[],间隔2
会得到:
2 x 4 x 5
然后再从1开始:
2 1 4 3 5
b[]符合好数定义
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5;
int n; long long a[N + 10], b[2 * N + 1];
int main() {
//freopen("in.txt", "r", stdin);
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> n;
for (int i = 1; i <= n; ++i)cin >> a[i];
sort(a + 1, a + 1 + n); int idx = 1;
cout << (n - 1) / 2 << endl;
for (int i = 2; i <= n; i += 2)b[i] = a[idx++];
for (int i = 1; i <= n; i += 2)b[i] = a[idx++];
for (int i = 1; i < idx; ++i)cout << b[i] << " ";
cout << endl;
}

Codeforces Round #671 (Div. 2) (A - B、D1题)的更多相关文章

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

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

  2. Codeforces Round #671 (Div. 2)

    比赛链接:https://codeforces.com/contest/1419 A. Digit Game 题意 给出一个 $n$ 位数,游戏规则如下: 1-indexed Raze标记奇数位 Br ...

  3. Codeforces Round #671 (Div. 2) B. Stairs 难度1200

    题目链接: Problem - 1419B - Codeforces 题目 题意 给x个格子,你可以用这x个格子去拼成楼梯 好的楼梯的要求如下: 1. 第n列有n个格子 2. 这个楼梯的所有格子可以被 ...

  4. Codeforces Round #671 (Div. 2) (A~E)

    Link~ 题面差评,整场都在读题 A 根据奇偶性判断一下即可. #include<bits/stdc++.h> #define ll long long #define N #defin ...

  5. Codeforces Round #671 (Div. 2) B. Stairs (递推)

    题意:一个台阶由一些单元格组成,如果一个高度为\(n\)的台阶中有\(n\)个不相邻的正方形(如图中的样例),就称这个台阶是"好台阶",现给你\(x\)个单元格,问最多能组成多少个 ...

  6. Codeforces Round #426 (Div. 2)A B C题+赛后小结

    最近比赛有点多,可是好像每场比赛都是被虐,单纯磨砺心态的作用.最近讲的内容也有点多,即便是点到为止很浅显的版块,刷了专题之后的状态还是~"咦,能做,可是并没有把握能A啊".每场网络 ...

  7. Codeforces Round #243 (Div. 2) B(思维模拟题)

    http://codeforces.com/contest/426/problem/B B. Sereja and Mirroring time limit per test 1 second mem ...

  8. Codeforces Round #340 (Div. 2) B. Chocolate 水题

    B. Chocolate 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co Bob loves everyt ...

  9. Codeforces Round #340 (Div. 2) A. Elephant 水题

    A. Elephant 题目连接: http://www.codeforces.com/contest/617/problem/A Descriptionww.co An elephant decid ...

  10. Codeforces Round #340 (Div. 2) D. Polyline 水题

    D. Polyline 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co There are three p ...

随机推荐

  1. JAVA学习week3

    本周由于c++小学期作业.未能按时学习JAVA 主要复习了基本语法 hello word 输出语法 输出格式的选择,进制的转换,注释的选择 还预习了变量相关的知识点

  2. super学习

    2022-10-02 16:27:38 super super代表的是"当前对象(this)"的父类型特征 概念 1.super是一个关键字,全部小写. 2.super和this对 ...

  3. 手撸一个SpringBoot配置中心实现配置动态刷新

    业务需求 SpringBoot项目配置信息大多使用@Value注解或者@ConfigurationProperties注解读取配置信息,线上项目经常需要对某些配置进行调整,如果每次都需要修改配置文件再 ...

  4. SpringBoot整合简单的定时任务~

    定时任务框架很多种Quartz,SpringTask,xxljob,PowerJob... 1.JDK提供的timer // JDK提供的 Timer timer = new Timer(); //t ...

  5. 华企盾DSC无缝替换其它加密软件两种方法

    有源码和大型图纸的使用第一种方案 第一种: 1.把DSCClient.exe和DSCService.exe添加到竞品的加密软件进程中,配置允许打开加密文件,加密类型不加密 2.安装DSC客户端后扫描加 ...

  6. eclipse工具使用

    eclipse下载 官网下载:https://www.eclipse.org/downloads/packages/ 打开后,找到Eclipse IDE for Java Developers点击进入 ...

  7. C++ Qt开发:SqlTableModel映射组件应用

    Qt 是一个跨平台C++图形界面开发库,利用Qt可以快速开发跨平台窗体应用程序,在Qt中我们可以通过拖拽的方式将不同组件放到指定的位置,实现图形化开发极大的方便了开发效率,本章将重点介绍SqlTabl ...

  8. Date、正则表达式练习

    Date.正则表达式练习 package com.guoba.date; import java.text.SimpleDateFormat; import java.util.Calendar; i ...

  9. 快速上手 dbt 数据转换工具 -- dbt core 命令进阶篇

    引 根据第一篇文章的约定,我想通过接下来的几篇文章带大家进一步了解 dbt 的用法,原计划这篇文章我会介绍 dbt 命令的进阶用法,进一步认识 dbt 的配置以及如何创建增量表等等零零散散十几个方面的 ...

  10. Python——第一章:if语法规则

    if语句的语法规则: ======第一种======        if 条件:            代码        如果条件成立就执行代码        如果不成立, 就不执行 案例1: mo ...